Skip to content

Commit

Permalink
Revert changes in Decompiler and StringUtils related to "\\R" handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyir committed Sep 26, 2023
1 parent 6c2c912 commit dd10ba6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
19 changes: 8 additions & 11 deletions core/src/main/java/com/taobao/arthas/core/util/Decompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,23 @@ private static String addLineNumber(String src, Map<Integer, Integer> lineMappin

StringBuilder sb = new StringBuilder();

List<String> lines = StringUtils.toLines(src);
String[] lines = src.split("\\R");

if (maxLineNumber >= 1000) {
formatStr = "/*%4d*/ ";
emptyStr = " ";
} else if (maxLineNumber >= 100) {
if (maxLineNumber >= 100) {
formatStr = "/*%3d*/ ";
emptyStr = " ";
} else if (maxLineNumber >= 1000) {
formatStr = "/*%4d*/ ";
emptyStr = " ";
}

int index = 0;
for (String line : lines) {
Integer srcLineNumber = lineMapping.get(index + 1);
for (int i = 0; i < lines.length; ++i) {
Integer srcLineNumber = lineMapping.get(i + 1);
if (srcLineNumber != null) {
sb.append(String.format(formatStr, srcLineNumber));
} else {
sb.append(emptyStr);
}
sb.append(line).append("\n");
index++;
sb.append(lines[i]).append("\n");
}

return sb.toString();
Expand Down
21 changes: 0 additions & 21 deletions core/src/main/java/com/taobao/arthas/core/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -909,27 +909,6 @@ public static String humanReadableByteCount(long bytes) {
: String.format("%.1f EiB", (bytes >> 20) / 0x1p40);
}

public static List<String> toLines(String text) {
List<String> result = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new StringReader(text));
try {
String line = reader.readLine();
while (line != null) {
result.add(line);
line = reader.readLine();
}
} catch (IOException exc) {
// quit
} finally {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
return result;
}

public static String randomString(int length) {
StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i++)
Expand Down

0 comments on commit dd10ba6

Please sign in to comment.