Committed by
Gerrit Code Review
Avoid unnecessary empty list instantiation
Change-Id: I128485be4e0d7d3400741855e4519f441cfb34c5
Showing
3 changed files
with
6 additions
and
5 deletions
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java
... | @@ -142,7 +142,7 @@ public class FlowModBuilderVer10 extends FlowModBuilder { | ... | @@ -142,7 +142,7 @@ public class FlowModBuilderVer10 extends FlowModBuilder { |
142 | switch (i.type()) { | 142 | switch (i.type()) { |
143 | case DROP: | 143 | case DROP: |
144 | log.warn("Saw drop action; assigning drop action"); | 144 | log.warn("Saw drop action; assigning drop action"); |
145 | - return new LinkedList<>(); | 145 | + return Collections.emptyList(); |
146 | case L2MODIFICATION: | 146 | case L2MODIFICATION: |
147 | acts.add(buildL2Modification(i)); | 147 | acts.add(buildL2Modification(i)); |
148 | break; | 148 | break; | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -194,7 +194,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -194,7 +194,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
194 | for (Instruction i : treatments) { | 194 | for (Instruction i : treatments) { |
195 | switch (i.type()) { | 195 | switch (i.type()) { |
196 | case DROP: | 196 | case DROP: |
197 | - return new LinkedList<>(); | 197 | + return Collections.emptyList(); |
198 | case L0MODIFICATION: | 198 | case L0MODIFICATION: |
199 | actions.add(buildL0Modification(i)); | 199 | actions.add(buildL0Modification(i)); |
200 | break; | 200 | break; | ... | ... |
... | @@ -51,6 +51,7 @@ import org.projectfloodlight.openflow.types.VlanPcp; | ... | @@ -51,6 +51,7 @@ import org.projectfloodlight.openflow.types.VlanPcp; |
51 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
52 | 52 | ||
53 | import java.util.ArrayList; | 53 | import java.util.ArrayList; |
54 | +import java.util.Collections; | ||
54 | import java.util.LinkedList; | 55 | import java.util.LinkedList; |
55 | import java.util.List; | 56 | import java.util.List; |
56 | import java.util.Optional; | 57 | import java.util.Optional; |
... | @@ -179,16 +180,16 @@ public final class GroupModBuilder { | ... | @@ -179,16 +180,16 @@ public final class GroupModBuilder { |
179 | } | 180 | } |
180 | 181 | ||
181 | private List<OFAction> buildActions(TrafficTreatment treatment) { | 182 | private List<OFAction> buildActions(TrafficTreatment treatment) { |
182 | - List<OFAction> actions = new LinkedList<>(); | ||
183 | if (treatment == null) { | 183 | if (treatment == null) { |
184 | - return actions; | 184 | + return Collections.emptyList(); |
185 | } | 185 | } |
186 | 186 | ||
187 | + List<OFAction> actions = new LinkedList<>(); | ||
187 | for (Instruction i : treatment.allInstructions()) { | 188 | for (Instruction i : treatment.allInstructions()) { |
188 | switch (i.type()) { | 189 | switch (i.type()) { |
189 | case DROP: | 190 | case DROP: |
190 | log.warn("Saw drop action; assigning drop action"); | 191 | log.warn("Saw drop action; assigning drop action"); |
191 | - return new LinkedList<>(); | 192 | + return Collections.emptyList(); |
192 | case L0MODIFICATION: | 193 | case L0MODIFICATION: |
193 | actions.add(buildL0Modification(i)); | 194 | actions.add(buildL0Modification(i)); |
194 | break; | 195 | break; | ... | ... |
-
Please register or login to post a comment