Opened 4 years ago
Closed 3 years ago
#22030 closed defect (wontfix)
[PATCH] Replace Utils.isStripEmpty with Utils.isBlank in AbstractPrimitive#put
| 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 isStripEmpty 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.
Attachments (3)
Change History (8)
by , 4 years ago
| Attachment: | flamegraph_isStripEmpty.png added |
|---|
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 4 years ago
| Milestone: | → 22.06 |
|---|---|
| Summary: | [PATCH][RFC] Replace Utils.isStripEmpty with Utils.isBlank in AbstractPrimitive#put → [PATCH] Replace Utils.isStripEmpty with Utils.isBlank in AbstractPrimitive#put |
comment:4 by , 3 years ago
| Milestone: | 22.06 → 22.07 |
|---|
comment:5 by , 3 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |






Utils#isStripEmpty (Java 8)