ctf: cache file name
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 23 Dec 2014 21:17:36 +0000 (16:17 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 21 Oct 2015 19:42:40 +0000 (15:42 -0400)
Java File.getName() gets a path and does a substring on it,
this operation is called on a per-event level and should be cached.

Change-Id: Ib8bd18df3bc0ac307f65fde615d151c832918a64
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/38740
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java

index ab051bb605356c83d85facbdc3c196906c072307..5c708e943d3239ec3d2f893feb2bd74628c3e339 100644 (file)
@@ -61,6 +61,11 @@ public class CTFStreamInput implements IDefinitionScope {
      */
     private final File fFile;
 
+    /**
+     * The file name
+     */
+    private final String fFileName;
+
     /**
      * The packet index of this input
      */
@@ -98,6 +103,12 @@ public class CTFStreamInput implements IDefinitionScope {
     public CTFStreamInput(CTFStream stream, File file) {
         fStream = stream;
         fFile = file;
+        String name = fFile.getName();
+        if (name == null) {
+            throw new IllegalStateException("File cannot have a null name"); //$NON-NLS-1$
+        }
+        fFileName = name;
+
         fIndex = new StreamInputPacketIndex();
         /*
          * Create the definitions we need to read the packet headers + contexts
@@ -144,11 +155,7 @@ public class CTFStreamInput implements IDefinitionScope {
      * @return the filename of the streaminput file.
      */
     public String getFilename() {
-        String name = fFile.getName();
-        if (name == null) {
-            throw new IllegalStateException("File cannot have a null name"); //$NON-NLS-1$
-        }
-        return name;
+        return fFileName;
     }
 
     /**
This page took 0.024853 seconds and 5 git commands to generate.