Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 3cd7a38

Browse files
⚡ Performance Improvement
1 parent b3735ba commit 3cd7a38

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎.github/DirectoryMaintainer.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.io.BufferedReader;
12
import java.io.File;
23
import java.io.FileInputStream;
34
import java.io.FileWriter;
@@ -27,16 +28,17 @@ public static void main(String[]a)throws Exception{
2728
builder.append(in.substring(0, in.indexOf("```shell")+8)).append("\n");
2829
in=in.substring(in.indexOf("```shell")+8);
2930
in=in.substring(in.indexOf("```"));
30-
final Process proc=Runtime.getRuntime().exec("tree -a -I .git "+System.getProperty("user.dir")+"/..");
31+
final Process proc=Runtime.getRuntime().exec("tree -a -I .git --noreport "+System.getProperty("user.dir")+"/..");
3132
try{
3233
proc.waitFor();
3334
}catch(Exception e){}
34-
try(final Scanner outputReader=new Scanner(new InputStreamReader(proc.getInputStream()))){
35+
try(final BufferedReader outputReader=new BufferedReader(new InputStreamReader(proc.getInputStream()))){
3536
final Pattern dirHeader=Pattern.compile("^/.*");
36-
while(outputReader.hasNext()){
37-
final String line=dirHeader.matcher(outputReader.nextLine()).replaceAll("");
38-
if(!line.isEmpty()&&outputReader.hasNext())
39-
builder.append(" ").append(line+"\n");
37+
String line;
38+
while((line=outputReader.readLine())!=null){
39+
line=dirHeader.matcher(line).replaceAll("");
40+
if(!line.isEmpty())
41+
builder.append(" ").append(line).append("\n");
4042
}
4143
}
4244
builder.append(in);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /