From: Matthew Khouzam Date: Thu, 1 Dec 2016 18:24:40 +0000 (-0500) Subject: ss: replace a for loop with a foreach operation X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=ff13758cfc4533e145830a3f617744ae6773eed9 ss: replace a for loop with a foreach operation And extract a constant Change-Id: If4e65223ed4e9ce617eb9da3023db0294ede151e Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/86172 Reviewed-by: Alexandre Montplaisir Reviewed-by: Hudson CI Tested-by: Marc-André Laperle --- diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java index 81b7feada9..8c8550eb6e 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java @@ -57,6 +57,7 @@ import com.google.common.collect.ImmutableSet; */ public class StateSystem implements ITmfStateSystemBuilder { + private static final int MAX_STACK_DEPTH = 100000; private static final String PARENT = ".."; //$NON-NLS-1$ private static final String WILDCARD = "*"; //$NON-NLS-1$ @@ -340,9 +341,7 @@ public class StateSystem implements ITmfStateSystemBuilder { } } else { if (element.equals(WILDCARD)) { - for (@NonNull Integer subquark : getSubAttributes(quark, false)) { - getQuarks(builder, subquark, remainder); - } + getSubAttributes(quark, false).forEach(subquark -> getQuarks(builder, subquark, remainder)); } else if (element.equals(PARENT)){ getQuarks(builder, getParentAttributeQuark(quark), remainder); } else { @@ -399,7 +398,7 @@ public class StateSystem implements ITmfStateSystemBuilder { throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Type:" + previousSV.getType() + ", Expected:" + Type.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - if (stackDepth >= 100000) { + if (stackDepth >= MAX_STACK_DEPTH) { /* * Limit stackDepth to 100000, to avoid having Attribute Trees grow * out of control due to buggy insertions