Changeset 15901 in josm for trunk


Ignore:
Timestamp:
2020-02-22T19:40:23+01:00 (4 years ago)
Author:
simon04
Message:

see #18749 - Intern strings to reduce memory footprint of svgSalamander

Location:
trunk/src/com/kitfox/svg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/SVGElement.java

    r14643 r15901  
    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;
     
    298299            String value = attrs.getValue(i);
    299300
    300             presAttribs.put(name, new StyleAttribute(name, value));
     301            presAttribs.put(name, new StyleAttribute(name, value == null ? null : value.intern()));
    301302        }
    302303    }
  • trunk/src/com/kitfox/svg/xml/StyleAttribute.java

    r8084 r15901  
    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
     
    8685    public StyleAttribute setName(String name)
    8786    {
    88         this.name = name;
     87        this.name = name == null ? null : name.intern();
    8988        return this;
    9089    }
     
    102101    public void setStringValue(String value)
    103102    {
    104         stringValue = value;
     103        stringValue = value == null ? null : value.intern();
    105104    }
    106105
Note: See TracChangeset for help on using the changeset viewer.