Reduce allocation from logging JEP-349-branch
authoregahlin
Thu, 29 Aug 2019 03:21:55 +0200
branchJEP-349-branch
changeset 57920 de358b994ad9
parent 57902 f6502e486572
child 57921 08327ab323c5
Reduce allocation from logging
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java	Wed Aug 28 12:03:58 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java	Thu Aug 29 03:21:55 2019 +0200
@@ -33,6 +33,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.NavigableMap;
 import java.util.Set;
 import java.util.SortedMap;
@@ -109,7 +110,9 @@
             SortedMap<Long, Path> after = pathSet.tailMap(timestamp);
             if (!after.isEmpty()) {
                 Path path = after.get(after.firstKey());
-                Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.TRACE, "Return path " + path + " for start time nanos " + timestamp);
+                if (Logger.shouldLog(LogTag.JFR_SYSTEM_STREAMING, LogLevel.TRACE)) {
+                    Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.TRACE, "Return path " + path + " for start time nanos " + timestamp);
+                }
                 return path;
             }
             if (!waitForPaths()) {