From cc7a469cb603cb75d605c0841359f83c870c45bd Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 23 Dec 2014 16:17:36 -0500 Subject: [PATCH] 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 --- .../ctf/core/trace/CTFStreamInput.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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; } /** -- 2.34.1