Changeset 16559 in josm


Ignore:
Timestamp:
2020-06-07T17:02:23+02:00 (4 years ago)
Author:
simon04
Message:

fix #19356, see #18750 - Deduplicate ImageryBounds

Reduces retained size of ImageryBounds from 3_372_384 to 1_985_952

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r16129 r16559  
    77import java.util.ArrayList;
    88import java.util.Arrays;
     9import java.util.HashMap;
    910import java.util.List;
    1011import java.util.Map;
     
    132133        private ImageryInfo mirrorEntry;
    133134        private ImageryBounds bounds;
     135        private Map<ImageryBounds, ImageryBounds> boundsInterner = new HashMap<>();
    134136        private Shape shape;
    135137        // language of last element, does only work for simple ENTRY_ATTRIBUTE's
     
    542544                break;
    543545            case BOUNDS:
    544                 entry.setBounds(bounds);
     546                entry.setBounds(intern(bounds));
    545547                bounds = null;
    546548                break;
     
    567569                // nothing to do for these or the unknown type
    568570            }
     571        }
     572
     573        private ImageryBounds intern(ImageryBounds imageryBounds) {
     574            return boundsInterner.computeIfAbsent(imageryBounds, ignore -> imageryBounds);
    569575        }
    570576    }
Note: See TracChangeset for help on using the changeset viewer.