Skip to content

Commit

Permalink
added BY_TEMP_HAS_NAME comparator to avoid its repeated construction …
Browse files Browse the repository at this point in the history
…during run-time
  • Loading branch information
phanecak-maptiler committed Dec 12, 2023
1 parent 612f700 commit d756038
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/openmaptiles/layers/Housenumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class Housenumber implements
private static final Pattern NO_CONVERSION_PATTERN = Pattern.compile("[^0-9;]");
private static final String TEMP_PARTITION = "_partition";
private static final String TEMP_HAS_NAME = "_has_name";
private static final Comparator<VectorTile.Feature> BY_TEMP_HAS_NAME = Comparator
.comparing(i -> (Boolean) i.attrs().get(TEMP_HAS_NAME), Boolean::compare);
private final Stats stats;

public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {
Expand Down Expand Up @@ -146,7 +148,7 @@ public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> l
.collect(Collectors.groupingBy(f -> f.attrs().get(TEMP_PARTITION)))
.values().stream()
.map(
g -> g.stream().min(Comparator.comparing(i -> (Boolean) i.attrs().get(TEMP_HAS_NAME), Boolean::compare))
g -> g.stream().min(BY_TEMP_HAS_NAME)
)
.filter(Optional::isPresent)
.map(Optional::get)
Expand Down

0 comments on commit d756038

Please sign in to comment.