From d7560388d8486497133560a850ace3d102119840 Mon Sep 17 00:00:00 2001 From: Peter Hanecak Date: Tue, 12 Dec 2023 10:50:02 +0100 Subject: [PATCH] added BY_TEMP_HAS_NAME comparator to avoid its repeated construction during run-time --- src/main/java/org/openmaptiles/layers/Housenumber.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openmaptiles/layers/Housenumber.java b/src/main/java/org/openmaptiles/layers/Housenumber.java index aee9afc0..4d54481b 100644 --- a/src/main/java/org/openmaptiles/layers/Housenumber.java +++ b/src/main/java/org/openmaptiles/layers/Housenumber.java @@ -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 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) { @@ -146,7 +148,7 @@ public List postProcess(int zoom, List 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)