Skip to content

Commit 40363e0

Browse files
author
changelcai
committed
fix stack filter
1 parent 002465c commit 40363e0

File tree

1 file changed

+6
-4
lines changed
  • matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/util

1 file changed

+6
-4
lines changed

matrix/matrix-android/matrix-trace-canary/src/main/java/com/tencent/matrix/trace/util/TraceDataUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public static String getTreeKey(List<MethodItem> stack, long stackCost) {
335335
StringBuilder ss = new StringBuilder();
336336
long allLimit = (long) (stackCost * Constants.FILTER_STACK_KEY_ALL_PERCENT);
337337

338-
List<MethodItem> sortList = new LinkedList<>();
338+
LinkedList<MethodItem> sortList = new LinkedList<>();
339339

340340
for (MethodItem item : stack) {
341341
if (item.durTime >= allLimit) {
@@ -350,14 +350,16 @@ public int compare(MethodItem o1, MethodItem o2) {
350350
}
351351
});
352352

353+
MethodItem root = stack.get(0);
353354
if (sortList.isEmpty() && !stack.isEmpty()) {
354-
sortList.add(stack.get(0));
355-
} else if (!sortList.isEmpty()) {
356-
sortList = sortList.subList(0, 1);
355+
sortList.add(root);
356+
} else if (sortList.size() > 1 && sortList.peek().methodId == root.methodId) {
357+
sortList.removeFirst();
357358
}
358359

359360
for (MethodItem item : sortList) {
360361
ss.append(item.methodId + "|");
362+
break;
361363
}
362364
return ss.toString();
363365
}

0 commit comments

Comments
 (0)