Skip to content

Commit

Permalink
Use Optional.ofNullable to avoid string length checks
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelabon committed Jun 4, 2024
1 parent f618385 commit dfcf644
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1120,14 +1120,9 @@ boolean isRestricted(Way currentWay, Way previousWay, Node commonNode) {
else if (rel.hasTag("type", "restriction") && rel.hasKey("restriction"))
return false;
else {
String routeValue = relation.get("route");
final String routeValue = Optional.ofNullable(relation.get("route")).map(it -> "restriction:" + it).orElse("");
for (String s : restrictions) {
if (s.length() <= 12)
continue;
String sub = s.substring(12);
if (routeValue.equals(sub) && rel.hasTag("type", s))
return false;
else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub))
if (routeValue.equals(s) && (rel.hasTag("type", s) || rel.hasKey(s)))
return false;
}
return true;
Expand Down

0 comments on commit dfcf644

Please sign in to comment.