diff options
author | Matthew Khouzam | 2014-07-28 19:18:15 +0000 |
---|---|---|
committer | Matthew Khouzam | 2014-08-02 21:11:28 +0000 |
commit | 2342c276c0a86805a262d6fd629da4a38ee5b48e (patch) | |
tree | 006c7d0682df555f422441d74ace20b6bbff9de0 /lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf | |
parent | 9ce08fa02886e4b833a29f774b842a4a83705fd5 (diff) | |
download | org.eclipse.linuxtools-2342c276c0a86805a262d6fd629da4a38ee5b48e.tar.gz org.eclipse.linuxtools-2342c276c0a86805a262d6fd629da4a38ee5b48e.tar.xz org.eclipse.linuxtools-2342c276c0a86805a262d6fd629da4a38ee5b48e.zip |
ctf: remove redundant code in structDeclaration
Change-Id: I0945d838d214cea852f5929c5c4ffbf4de6d50b6
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/30836
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Diffstat (limited to 'lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf')
-rw-r--r-- | lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java index a4d60b145f..92e024029e 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java @@ -167,16 +167,7 @@ public class StructDeclaration extends Declaration { alignRead(input); final Definition[] myFields = new Definition[fFieldMap.size()]; StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldName, fFieldMap.keySet(), myFields); - - Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator(); - for (int i = 0; i < fFieldMap.size(); i++) { - Map.Entry<String, IDeclaration> entry = iter.next(); - String name = entry.getKey(); - if (name == null) { - throw new IllegalStateException(); - } - myFields[i] = entry.getValue().createDefinition(structDefinition, name, input); - } + fillStruct(input, myFields, structDefinition); return structDefinition; } @@ -203,15 +194,7 @@ public class StructDeclaration extends Declaration { */ @SuppressWarnings("null") StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldScope, fieldScope.getName(), fFieldMap.keySet(), myFields); - Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator(); - for (int i = 0; i < fFieldMap.size(); i++) { - Map.Entry<String, IDeclaration> entry = iter.next(); - String fieldName = entry.getKey(); - if (fieldName == null) { - throw new IllegalStateException(); - } - myFields[i] = entry.getValue().createDefinition(structDefinition, fieldName, input); - } + fillStruct(input, myFields, structDefinition); return structDefinition; } @@ -228,6 +211,15 @@ public class StructDeclaration extends Declaration { fMaxAlign = Math.max(fMaxAlign, declaration.getAlignment()); } + @SuppressWarnings("null") + private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFReaderException { + Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator(); + for (int i = 0; i < fFieldMap.size(); i++) { + Map.Entry<String, IDeclaration> entry = iter.next(); + myFields[i] = entry.getValue().createDefinition(structDefinition, entry.getKey(), input); + } + } + @Override public String toString() { /* Only used for debugging */ |