Opened 4 years ago

Last modified 4 years ago

#22030 closed defect

[PATCH][RFC] Replace Utils.isStripEmpty with Utils.isBlank in AbstractPrimitive#put — at Initial Version

Reported by: taylor.smock Owned by: team
Priority: normal Milestone: 22.07
Component: Core Version:
Keywords: performance Cc:

Description

I've been doing some profiling with Vector tiles, and I've noticed that makes a significant number of allocations.

Looking at the profiler output, it looks like Utils.isBlank effectively gets optimized away (tested on Java 8/17). Does anyone know of a reason to keep Utils.isStripEmpty?

  • src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    diff --git a/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java b/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
    index b4b1e1e339..92b1572a11 100644
    a b public abstract class AbstractPrimitive implements IPrimitive, IFilterablePrimit  
    584584    @Override
    585585    public void put(String key, String value) {
    586586        Map<String, String> originalKeys = getKeys();
    587         if (key == null || Utils.isStripEmpty(key))
     587        if (key == null || Utils.isBlank(key))
    588588            return;
    589589        else if (value == null) {
    590590            remove(key);

Profiler output:

Change History (3)

by taylor.smock, 4 years ago

Attachment: flamegraph_isStripEmpty.png added

Utils#isStripEmpty (Java 8)

by taylor.smock, 4 years ago

Utils#isBlank (Java 17)

by taylor.smock, 4 years ago

Utils#isBlank (Java 8)

Note: See TracTickets for help on using tickets.