Skip to content

Commit

Permalink
Small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Mar 19, 2017
1 parent c044004 commit 7cafa15
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -151,9 +151,7 @@ private <T extends NodeWithModifiers<?> & NodeWithRange<?>> void validateModifie
if (hasStrictfp) {
validateAtMostOneOf(n, reporter, NATIVE, STRICTFP);
} else {
final List<Modifier> newModifiers = new ArrayList<>(asList(allowedModifiers));
newModifiers.remove(STRICTFP);
allowedModifiers = newModifiers.toArray(new Modifier[0]);
allowedModifiers = removeModifierFromArray(STRICTFP, allowedModifiers);
}
for (Modifier m : n.getModifiers()) {
if (!arrayContains(allowedModifiers, m)) {
Expand All @@ -162,6 +160,13 @@ private <T extends NodeWithModifiers<?> & NodeWithRange<?>> void validateModifie
}
}

private Modifier[] removeModifierFromArray(Modifier m, Modifier[] allowedModifiers) {
final List<Modifier> newModifiers = new ArrayList<>(asList(allowedModifiers));
newModifiers.remove(m);
allowedModifiers = newModifiers.toArray(new Modifier[0]);
return allowedModifiers;
}

private boolean arrayContains(Object[] items, Object searchItem) {
for (Object o : items) {
if (o == searchItem) {
Expand Down

0 comments on commit 7cafa15

Please sign in to comment.