Opened 3 years ago
Last modified 3 years ago
#22030 closed defect
[PATCH][RFC] Replace Utils.isStripEmpty with Utils.isBlank in AbstractPrimitive#put — at Version 1
Reported by: | taylor.smock | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 22.07 |
Component: | Core | Version: | |
Keywords: | performance | Cc: |
Description (last modified by )
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 584 584 @Override 585 585 public void put(String key, String value) { 586 586 Map<String, String> originalKeys = getKeys(); 587 if (key == null || Utils.is StripEmpty(key))587 if (key == null || Utils.isBlank(key)) 588 588 return; 589 589 else if (value == null) { 590 590 remove(key);
Allocations:
- Utils#isStripEmpty: 112 MB
- Arrays#copyOf: 57 MB
- AbstractPrimitive#getKeys: 25 MB
- String[]: 4 MB
Allocations:
- Arrays#copyOf: 61 MB
- AbstractPrimitive#getKeys: 3.5 MB
- String[]: 2.3 MB
Allocations:
- Arrays#copyOf: 21 MB
- AbstractPrimitive#getKeys: 43 MB
- String[]: 12 MB
There is a bit of jitter, but the primary cost of AbstractPrimitive#put is from Utils#isStripEmpty
.
Change History (4)
by , 3 years ago
Attachment: | flamegraph_isStripEmpty.png added |
---|
comment:1 by , 3 years ago
Description: | modified (diff) |
---|
Utils#isStripEmpty (Java 8)