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
|
| 259 | 259 | this.id = attrs.getValue("id"); |
| 260 | 260 | if (this.id != null && !this.id.equals("")) |
| 261 | 261 | { |
| | 262 | this.id = this.id.intern(); |
| 262 | 263 | diagram.setElement(this.id, this); |
| 263 | 264 | } |
| 264 | 265 | |
| 265 | 266 | String className = attrs.getValue("class"); |
| 266 | | this.cssClass = (className == null || className.equals("")) ? null : className; |
| | 267 | this.cssClass = (className == null || className.equals("")) ? null : className.intern(); |
| 267 | 268 | //docRoot = helper.docRoot; |
| 268 | 269 | //universe = helper.universe; |
| 269 | 270 | |
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()
|
| 69 | 69 | |
| 70 | 70 | public StyleAttribute(String name) |
| 71 | 71 | { |
| 72 | | this.name = name; |
| 73 | | stringValue = null; |
| | 72 | this(name, null); |
| 74 | 73 | } |
| 75 | 74 | |
| 76 | 75 | public StyleAttribute(String name, String stringValue) |
| 77 | 76 | { |
| 78 | | this.name = name; |
| 79 | | this.stringValue = stringValue; |
| | 77 | setName(name); |
| | 78 | setStringValue(stringValue); |
| 80 | 79 | } |
| 81 | 80 | |
| 82 | 81 | public String getName() { |
| … |
… |
public String getName() {
|
| 85 | 84 | |
| 86 | 85 | public StyleAttribute setName(String name) |
| 87 | 86 | { |
| 88 | | this.name = name; |
| | 87 | this.name = name == null ? null : name.intern(); |
| 89 | 88 | return this; |
| 90 | 89 | } |
| 91 | 90 | |
| … |
… |
public String getStringValue()
|
| 101 | 100 | |
| 102 | 101 | public void setStringValue(String value) |
| 103 | 102 | { |
| 104 | | stringValue = value; |
| | 103 | stringValue = value == null ? null : value.intern(); |
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | public boolean getBooleanValue() { |
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) {
|
| 396 | 396 | max_zoom = i.defaultMaxZoom; |
| 397 | 397 | min_zoom = i.defaultMinZoom; |
| 398 | 398 | cookies = i.cookies; |
| 399 | | icon = i.icon; |
| | 399 | icon = i.icon == null ? null : i.icon.intern(); |
| 400 | 400 | description = i.description; |
| 401 | 401 | category = i.category != null ? i.category.getCategoryString() : null; |
| 402 | 402 | if (i.bounds != null) { |
| … |
… |
public ImageryInfo(ImageryPreferenceEntry e) {
|
| 567 | 567 | termsOfUseText = e.terms_of_use_text; |
| 568 | 568 | termsOfUseURL = e.terms_of_use_url; |
| 569 | 569 | countryCode = e.country_code; |
| 570 | | icon = e.icon; |
| | 570 | icon = e.icon == null ? null : e.icon.intern(); |
| 571 | 571 | if (e.noTileHeaders != null) { |
| 572 | 572 | noTileHeaders = e.noTileHeaders.toMap(); |
| 573 | 573 | } |
| … |
… |
public ImageryInfo(ImageryInfo i) {
|
| 632 | 632 | this.bestMarked = i.bestMarked; |
| 633 | 633 | this.overlay = i.overlay; |
| 634 | 634 | // do not copy field {@code mirrors} |
| 635 | | this.icon = i.icon; |
| | 635 | this.icon = i.icon == null ? null : i.icon.intern(); |
| 636 | 636 | this.isGeoreferenceValid = i.isGeoreferenceValid; |
| 637 | 637 | this.defaultLayers = i.defaultLayers; |
| 638 | 638 | this.customHttpHeaders = i.customHttpHeaders; |
| … |
… |
public String getIcon() {
|
| 1189 | 1189 | * @param icon The entry icon |
| 1190 | 1190 | */ |
| 1191 | 1191 | public void setIcon(String icon) { |
| 1192 | | this.icon = icon; |
| | 1192 | this.icon = icon == null ? null : icon.intern(); |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | /** |
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
|
|
| 76 | 76 | * @param definition projection definition (EPSG format) |
| 77 | 77 | */ |
| 78 | 78 | 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(); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
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
|
| 330 | 330 | } |
| 331 | 331 | try { |
| 332 | 332 | 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) |
| 334 | 335 | : ai.val instanceof String |
| 335 | 336 | ? (String) ai.val |
| 336 | 337 | : ai.val instanceof Keyword |
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
|
|
| 23 | 23 | * @param val The string value that is written in the MapCSS file |
| 24 | 24 | */ |
| 25 | 25 | public Keyword(String val) { |
| 26 | | this.val = val.toLowerCase(Locale.ENGLISH); |
| | 26 | this.val = val.toLowerCase(Locale.ENGLISH).intern(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | @Override |
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() {
|
| 95 | 95 | * @param key The tag name |
| 96 | 96 | */ |
| 97 | 97 | public TagKeyReference(String key) { |
| 98 | | this.key = key; |
| | 98 | this.key = key.intern(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | @Override |
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() {
|
| 51 | 51 | public final boolean isSetInstruction; |
| 52 | 52 | |
| 53 | 53 | public AssignmentInstruction(String key, Object val, boolean isSetInstruction) { |
| 54 | | this.key = key; |
| | 54 | this.key = key.intern(); |
| 55 | 55 | this.isSetInstruction = isSetInstruction; |
| 56 | 56 | if (val instanceof LiteralExpression) { |
| 57 | 57 | Object litValue = ((LiteralExpression) val).evaluate(null); |
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() {
|
| 484 | 484 | final List<PresetListEntry> entries = new ArrayList<>(valueArray.length); |
| 485 | 485 | for (int i = 0; i < valueArray.length; i++) { |
| 486 | 486 | 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 |
| 488 | 488 | ? displayArray[i] |
| 489 | 489 | : trc(values_context, fixPresetString(displayArray[i])); |
| | 490 | e.locale_display_value = value == null ? null : value.intern(); |
| 490 | 491 | if (shortDescriptionsArray != null) { |
| 491 | | e.locale_short_description = locale_short_descriptions != null |
| | 492 | final String description = locale_short_descriptions != null |
| 492 | 493 | ? shortDescriptionsArray[i] |
| 493 | 494 | : tr(fixPresetString(shortDescriptionsArray[i])); |
| | 495 | e.locale_short_description = description == null ? null : description.intern(); |
| 494 | 496 | } |
| 495 | 497 | |
| 496 | 498 | entries.add(e); |
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))
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | private void setValue(Entry entry, String fieldName, String value) throws SAXException { |
| | 140 | if (value != null) { |
| | 141 | value = value.intern(); |
| | 142 | } |
| 140 | 143 | CheckParameterUtil.ensureParameterNotNull(entry, "entry"); |
| 141 | 144 | if ("class".equals(fieldName) || "default".equals(fieldName) || "throw".equals(fieldName) || |
| 142 | 145 | "new".equals(fieldName) || "null".equals(fieldName)) { |