aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-03 05:00:04 (EST)
committerMatthew Khouzam2013-12-03 11:28:59 (EST)
commit4b1e3ade300a916bff48d5e28c5ccdd11f732ca1 (patch)
tree3afb9f994a82839c4fa9ce4a403327c7b3b0bdd3
parente3440ffb229f531392281457fede97613aff4f5d (diff)
downloadorg.eclipse.linuxtools-4b1e3ade300a916bff48d5e28c5ccdd11f732ca1.zip
org.eclipse.linuxtools-4b1e3ade300a916bff48d5e28c5ccdd11f732ca1.tar.gz
org.eclipse.linuxtools-4b1e3ade300a916bff48d5e28c5ccdd11f732ca1.tar.bz2
ctf: avoid temporary array creation when parsing CTF-Array.refs/changes/40/19240/2
The temporary List<long> is useless and the conversion function too. Change-Id: I42bb50536deb1529998287fd9dae34c5f009c194 Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Reviewed-on: https://git.eclipse.org/r/19240 Tested-by: Hudson CI Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java26
1 files changed, 7 insertions, 19 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
index a38cf78..6277e95 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
@@ -113,12 +113,11 @@ public abstract class CtfTmfEventField extends TmfEventField {
} else if (arrayDecl.getElementType() instanceof IntegerDeclaration) {
/* This is a an array of CTF Integers */
- List<Long> values = new ArrayList<Long>(arrayDecl.getLength());
+ long[] values = new long[arrayDecl.getLength()];
for (int i = 0; i < arrayDecl.getLength(); i++) {
- values.add(((IntegerDefinition) arrayDef.getElem(i)).getValue());
+ values[i] = ((IntegerDefinition) arrayDef.getElem(i)).getValue();
}
- long[] valuesArray = convertListToArray(values);
- field = new CTFIntegerArrayField(fieldName, valuesArray,
+ field = new CTFIntegerArrayField(fieldName, values,
((IntegerDeclaration) arrayDecl.getElementType()).getBase(),
((IntegerDeclaration) arrayDecl.getElementType()).isSigned());
}
@@ -136,14 +135,14 @@ public abstract class CtfTmfEventField extends TmfEventField {
field = new CTFStringField(fieldName, seqDef.toString());
} else if (seqDecl.getElementType() instanceof IntegerDeclaration) {
/* Sequence of integers => CTFIntegerArrayField */
- List<Long> values = new ArrayList<Long>(seqDef.getLength());
+ long[] values = new long[seqDef.getLength()];
for (int i = 0; i < seqDef.getLength(); i++) {
- values.add(((IntegerDefinition) seqDef.getElem(i)).getValue());
+ values[i] = ((IntegerDefinition) seqDef.getElem(i)).getValue();
}
- long[] valuesArray = convertListToArray(values);
- field = new CTFIntegerArrayField(fieldName, valuesArray,
+ field = new CTFIntegerArrayField(fieldName, values,
((IntegerDeclaration) seqDecl.getElementType()).getBase(),
((IntegerDeclaration) seqDecl.getElementType()).isSigned());
+
}
/* Add other Sequence types here */
@@ -191,17 +190,6 @@ public abstract class CtfTmfEventField extends TmfEventField {
return getName() + '=' + getFormattedValue();
}
- /**
- * We cannot use List.toArray(T[]) for primitives types, so do it manually.
- */
- private static long[] convertListToArray(List<Long> list) {
- long[] array = new long[list.size()];
- for (int i = 0; i < list.size(); i++) {
- array[i] = list.get(i);
- }
- return array;
- }
-
}
/**