Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[memory] intern ConfigurationElement.propertiesAndValue #536

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -110,14 +112,32 @@ 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() {
return propertiesAndValue;
}

void setValue(String value) {
value = intern(value);
if (propertiesAndValue.length == 0) {
propertiesAndValue = new String[] { value };
return;
Expand Down
Loading