From 52bce90ac50f06b00bb9fabcb00b47323b1ebe54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Wed, 21 Feb 2024 14:44:09 +0100 Subject: [PATCH 1/2] [memory] intern ConfigurationElement.propertiesAndValue o.e.core.internal.registry.ConfigurationElement.propertiesAndValue is likely to contain duplicate Strings like "true" --- .../registry/ConfigurationElement.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java index 8df0752b4b5..f6d2bd9f35a 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java @@ -23,7 +23,9 @@ * plug-in manifest. */ public class ConfigurationElement extends RegistryObject { + static final ConfigurationElement[] EMPTY_ARRAY = new ConfigurationElement[0]; + private static final String[] EMPTY_STRINGS = new String[0]; // The id of the parent element. It can be a configuration element or an // extension @@ -60,7 +62,7 @@ protected ConfigurationElement(int self, String contributorId, String name, Stri setObjectId(self); this.contributorId = contributorId; this.name = name; - this.propertiesAndValue = propertiesAndValue; + this.propertiesAndValue = intern(propertiesAndValue); setRawChildren(children); setExtraDataOffset(extraDataOffset); parentId = parent; @@ -110,7 +112,24 @@ protected String[] getAttributeNames() { } void setProperties(String[] value) { - propertiesAndValue = value; + propertiesAndValue = intern(value); + } + + private static String[] intern(String[] a) { + if (a == null) { + return null; + } + if (a.length == 0) { + return EMPTY_STRINGS; + } + for (int i = 0; i < a.length; i++) { + a[i] = intern(a[i]); + } + return a; + } + + private static String intern(String s) { + return s == null ? null : s.intern(); } protected String[] getPropertiesAndValue() { @@ -118,6 +137,7 @@ protected String[] getPropertiesAndValue() { } void setValue(String value) { + value = intern(value); if (propertiesAndValue.length == 0) { propertiesAndValue = new String[] { value }; return; From 051634edbeb415deab8824c1bfab870c45fe9d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Tue, 5 Mar 2024 12:06:12 +0100 Subject: [PATCH 2/2] version bump --- bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF index 4b982aa25b2..b134a4caf23 100644 --- a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.registry;singleton:=true -Bundle-Version: 3.12.0.qualifier +Bundle-Version: 3.12.100.qualifier Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.adapter;x-internal:=true, org.eclipse.core.internal.registry;x-friends:="org.eclipse.core.runtime",