Changeset 19286 in josm for trunk


Ignore:
Timestamp:
2025-01-17T11:48:11+01:00 (3 weeks ago)
Author:
taylor.smock
Message:

See #24075: Reduce memory allocations for TaggingPresetItem#matches

Make PMD happy again.

As noted in the comments for the for loop in question, this is a fairly
significant performance optimization. The for-each loop that PMD prefers has
significant penalties on hot code sections for ArrayList objects, which we use
extensively.

TBH, the JVM should probably do this optimization for (at minimum) ArrayList
objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r19285 r19286  
    180180             * Overall improvement: 7.6 hours to 4.5 hours for validating a Colorado pbf extract (40% improvement).
    181181             */
    182             for (int i = 0; i < items.size(); i++) { // READ ABOVE: DO NOT REPLACE WITH ENHANCED FOR LOOP WITHOUT PROFILING!
     182            for (int i = 0; i < items.size(); i++) { // NOPMD READ ABOVE: DO NOT REPLACE WITH ENHANCED FOR LOOP WITHOUT PROFILING!
    183183                TaggingPresetItem item = items.get(i);
    184184                Boolean m = item.matches(tags);
Note: See TracChangeset for help on using the changeset viewer.