Changeset 15902 in josm


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

see #18749 - Intern strings to reduce memory footprint

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r15739 r15902  
    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;
     
    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();
     
    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;
     
    11901190     */
    11911191    public void setIcon(String icon) {
    1192         this.icon = icon;
     1192        this.icon = icon == null ? null : icon.intern();
    11931193    }
    11941194
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r15717 r15902  
    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    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15900 r15902  
    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
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Keyword.java

    r12378 r15902  
    2424     */
    2525    public Keyword(String val) {
    26         this.val = val.toLowerCase(Locale.ENGLISH);
     26        this.val = val.toLowerCase(Locale.ENGLISH).intern();
    2727    }
    2828
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r15889 r15902  
    9696         */
    9797        public TagKeyReference(String key) {
    98             this.key = key;
     98            this.key = key.intern();
    9999        }
    100100
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java

    r12379 r15902  
    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) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r13597 r15902  
    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
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r15710 r15902  
    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) ||
Note: See TracChangeset for help on using the changeset viewer.