Skip to content

Commit 54b4f67

Browse files
committed
GH-551 use set for threadIds; presize HashMap-s to avoid their resizing
1 parent a322588 commit 54b4f67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/StackTraceSnapshotBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private long getThreadId() {
270270

271271
}
272272

273-
final List<Long> threadIds = new ArrayList<>();
273+
final Set<Long> threadIds = new HashSet<>();
274274
final List<String> threadNames = new ArrayList<>();
275275
final List<byte[]> threadCompactData = new ArrayList<>();
276276
final List<MethodInfo> methodInfos = new ArrayList<>();
@@ -350,7 +350,7 @@ final void addStacktrace(SampledThreadInfo[] threads, long dumpTimeStamp) throws
350350

351351
if (timediff < 0) return;
352352
synchronized (lock) {
353-
Map<Long,SampledThreadInfo> tinfoMap = new HashMap();
353+
Map<Long,SampledThreadInfo> tinfoMap = new HashMap(threads.length);
354354

355355
for (SampledThreadInfo tinfo : threads) {
356356
tinfoMap.put(tinfo.getThreadId(),tinfo);
@@ -390,7 +390,7 @@ final public void addStacktrace(java.lang.management.ThreadInfo[] threads, long
390390

391391
if (timediff < 0) return;
392392
synchronized (lock) {
393-
Map<Long,SampledThreadInfo> tinfoMap = new HashMap();
393+
Map<Long,SampledThreadInfo> tinfoMap = new HashMap(threads.length);
394394

395395
// if (stackTraceCount%builderBatchSize == 0) {
396396
// ccgb.doBatchStart();

0 commit comments

Comments
 (0)