From: Matthew Khouzam Date: Tue, 23 Dec 2014 21:17:36 +0000 (-0500) Subject: ctf: cache file name X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=cc7a469cb603cb75d605c0841359f83c870c45bd;p=deliverable%2Ftracecompass.git ctf: cache file name 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 Reviewed-on: https://git.eclipse.org/r/38740 Reviewed-by: Hudson CI Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java index ab051bb605..5c708e943d 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java @@ -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; } /**