Ticket #18749: 18749.patch

File 18749.patch, 9.6 KB (added by simon04, 6 years ago)
  • src/com/kitfox/svg/SVGElement.java

    commit 097ff20c6e217cde9dfb06eed0b24eff5830a2b7
    Author: Simon Legner <Simon.Legner@gmail.com>
    Date:   2020-02-22 17:04:04 +0100
    
        see #18749 - Intern strings to reduce memory footprint
    
    diff --git a/src/com/kitfox/svg/SVGElement.java b/src/com/kitfox/svg/SVGElement.java
    index e41c31193..70fa9db1f 100644
    a b public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElem  
    259259        this.id = attrs.getValue("id");
    260260        if (this.id != null && !this.id.equals(""))
    261261        {
     262            this.id = this.id.intern();
    262263            diagram.setElement(this.id, this);
    263264        }
    264265
    265266        String className = attrs.getValue("class");
    266         this.cssClass = (className == null || className.equals("")) ? null : className;
     267        this.cssClass = (className == null || className.equals("")) ? null : className.intern();
    267268        //docRoot = helper.docRoot;
    268269        //universe = helper.universe;
    269270
  • src/com/kitfox/svg/xml/StyleAttribute.java

    diff --git a/src/com/kitfox/svg/xml/StyleAttribute.java b/src/com/kitfox/svg/xml/StyleAttribute.java
    index 6e8f0f985..2dd98c6cd 100644
    a b public StyleAttribute()  
    6969   
    7070    public StyleAttribute(String name)
    7171    {
    72         this.name = name;
    73         stringValue = null;
     72        this(name, null);
    7473    }
    7574
    7675    public StyleAttribute(String name, String stringValue)
    7776    {
    78         this.name = name;
    79         this.stringValue = stringValue;
     77        setName(name);
     78        setStringValue(stringValue);
    8079    }
    8180
    8281    public String getName() {
    public String getName() {  
    8584   
    8685    public StyleAttribute setName(String name)
    8786    {
    88         this.name = name;
     87        this.name = name == null ? null : name.intern();
    8988        return this;
    9089    }
    9190   
    public String getStringValue()  
    101100
    102101    public void setStringValue(String value)
    103102    {
    104         stringValue = value;
     103        stringValue = value == null ? null : value.intern();
    105104    }
    106105
    107106    public boolean getBooleanValue() {
  • src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    diff --git a/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java b/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
    index 50cfb87ed..9295987a1 100644
    a b public ImageryPreferenceEntry(ImageryInfo i) {  
    396396            max_zoom = i.defaultMaxZoom;
    397397            min_zoom = i.defaultMinZoom;
    398398            cookies = i.cookies;
    399             icon = i.icon;
     399            icon = i.icon == null ? null : i.icon.intern();
    400400            description = i.description;
    401401            category = i.category != null ? i.category.getCategoryString() : null;
    402402            if (i.bounds != null) {
    public ImageryInfo(ImageryPreferenceEntry e) {  
    567567        termsOfUseText = e.terms_of_use_text;
    568568        termsOfUseURL = e.terms_of_use_url;
    569569        countryCode = e.country_code;
    570         icon = e.icon;
     570        icon = e.icon == null ? null : e.icon.intern();
    571571        if (e.noTileHeaders != null) {
    572572            noTileHeaders = e.noTileHeaders.toMap();
    573573        }
    public ImageryInfo(ImageryInfo i) {  
    632632        this.bestMarked = i.bestMarked;
    633633        this.overlay = i.overlay;
    634634        // do not copy field {@code mirrors}
    635         this.icon = i.icon;
     635        this.icon = i.icon == null ? null : i.icon.intern();
    636636        this.isGeoreferenceValid = i.isGeoreferenceValid;
    637637        this.defaultLayers = i.defaultLayers;
    638638        this.customHttpHeaders = i.customHttpHeaders;
    public String getIcon() {  
    11891189     * @param icon The entry icon
    11901190     */
    11911191    public void setIcon(String icon) {
    1192         this.icon = icon;
     1192        this.icon = icon == null ? null : icon.intern();
    11931193    }
    11941194
    11951195    /**
  • src/org/openstreetmap/josm/data/projection/Projections.java

    diff --git a/src/org/openstreetmap/josm/data/projection/Projections.java b/src/org/openstreetmap/josm/data/projection/Projections.java
    index a4bb31f9e..fbb9c03f8 100644
    a b  
    7676         * @param definition projection definition (EPSG format)
    7777         */
    7878        public ProjectionDefinition(String code, String name, String definition) {
    79             this.code = code;
    80             this.name = name;
    81             this.definition = definition;
     79            this.code = code.intern();
     80            this.name = name.intern();
     81            this.definition = definition.intern();
    8282        }
    8383    }
    8484
  • src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    diff --git a/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java b/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
    index b5028bc71..0c2ab9ffc 100644
    a b static TagCheck ofMapCSSRule(final GroupedMapCSSRule rule) throws IllegalDataExc  
    330330                    }
    331331                    try {
    332332                        final String val = ai.val instanceof Expression
    333                                 ? Optional.ofNullable(((Expression) ai.val).evaluate(new Environment())).map(Object::toString).orElse(null)
     333                                ? Optional.ofNullable(((Expression) ai.val).evaluate(new Environment()))
     334                                        .map(Object::toString).map(String::intern).orElse(null)
    334335                                : ai.val instanceof String
    335336                                ? (String) ai.val
    336337                                : ai.val instanceof Keyword
  • src/org/openstreetmap/josm/gui/mappaint/Keyword.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/Keyword.java b/src/org/openstreetmap/josm/gui/mappaint/Keyword.java
    index 3cddda625..4dd9197d4 100644
    a b  
    2323     * @param val The string value that is written in the MapCSS file
    2424     */
    2525    public Keyword(String val) {
    26         this.val = val.toLowerCase(Locale.ENGLISH);
     26        this.val = val.toLowerCase(Locale.ENGLISH).intern();
    2727    }
    2828
    2929    @Override
  • src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java b/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
    index f5d4b98d4..8b8addbc7 100644
    a b private MapPaintStyles() {  
    9595         * @param key The tag name
    9696         */
    9797        public TagKeyReference(String key) {
    98             this.key = key;
     98            this.key = key.intern();
    9999        }
    100100
    101101        @Override
  • src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java
    index 793b85eaa..0647da838 100644
    a b public String toString() {  
    5151        public final boolean isSetInstruction;
    5252
    5353        public AssignmentInstruction(String key, Object val, boolean isSetInstruction) {
    54             this.key = key;
     54            this.key = key.intern();
    5555            this.isSetInstruction = isSetInstruction;
    5656            if (val instanceof LiteralExpression) {
    5757                Object litValue = ((LiteralExpression) val).evaluate(null);
  • src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
    index d3d3c2c73..b967dbcee 100644
    a b private void initListEntriesFromAttributes() {  
    484484        final List<PresetListEntry> entries = new ArrayList<>(valueArray.length);
    485485        for (int i = 0; i < valueArray.length; i++) {
    486486            final PresetListEntry e = new PresetListEntry(valueArray[i]);
    487             e.locale_display_value = locale_display_values != null || values_no_i18n
     487            final String value = locale_display_values != null || values_no_i18n
    488488                    ? displayArray[i]
    489489                    : trc(values_context, fixPresetString(displayArray[i]));
     490            e.locale_display_value = value == null ? null : value.intern();
    490491            if (shortDescriptionsArray != null) {
    491                 e.locale_short_description = locale_short_descriptions != null
     492                final String description = locale_short_descriptions != null
    492493                        ? shortDescriptionsArray[i]
    493494                        : tr(fixPresetString(shortDescriptionsArray[i]));
     495                e.locale_short_description = description == null ? null : description.intern();
    494496            }
    495497
    496498            entries.add(e);
  • src/org/openstreetmap/josm/tools/XmlObjectParser.java

    diff --git a/src/org/openstreetmap/josm/tools/XmlObjectParser.java b/src/org/openstreetmap/josm/tools/XmlObjectParser.java
    index 89c8b3eaa..05c6058ce 100644
    a b else if (Double.class.equals(klass))  
    137137        }
    138138
    139139        private void setValue(Entry entry, String fieldName, String value) throws SAXException {
     140            if (value != null) {
     141                value = value.intern();
     142            }
    140143            CheckParameterUtil.ensureParameterNotNull(entry, "entry");
    141144            if ("class".equals(fieldName) || "default".equals(fieldName) || "throw".equals(fieldName) ||
    142145                    "new".equals(fieldName) || "null".equals(fieldName)) {