Skip to content

Commit

Permalink
Prefer a length check over creating a new array
Browse files Browse the repository at this point in the history
Responding to feedback that there was too much unnecessary complexity
introduced by creating a `restrictionTypes` array based
off of the `restrictions` array.
  • Loading branch information
michaelabon committed Jun 4, 2024
1 parent 0ad37fa commit 53ba13c
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1122,19 +1122,14 @@ else if (rel.hasTag("type", "restriction") && rel.hasKey("restriction"))
else {
boolean remove = true;
String routeValue = relation.get("route");
String[] restrictionTypes = Arrays.stream(restrictions)
.filter(s -> s.startsWith("restriction:"))
.map(s -> s.substring("restriction:".length()))
.toArray(String[]::new);

for (String type : restrictionTypes) {
if (!routeValue.equals(type)) {
for (String s : restrictions) {
if (s.length() <= 12)
continue;
}

if (rel.hasKey("restriction:" + type) || rel.hasTag("type", type)) {
String sub = s.substring(12);
if (routeValue.equals(sub) && rel.hasTag("type", s))
remove = false;
else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub))
remove = false;
}
}
return remove;
}
Expand Down

0 comments on commit 53ba13c

Please sign in to comment.