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

Remove now unnecessary calls to String.intern() in PreferencesService #462

Merged

Conversation

HannesWell
Copy link
Member

@HannesWell HannesWell commented Dec 23, 2023

The preference keys on which String.intern() is called are already interned when they are put into the EclipsePreferences object since #33.

Not calling intern again avoids the overhead of it.

The preference keys on which String.intern() is called are already
interned when they are put into the EclipsePreferences object since
eclipse-equinox#33
Comment on lines +147 to +151
if (!propsToRemove.isEmpty() && !(globalNode instanceof EclipsePreferences)) {
// intern strings we import because some people in their property change
// listeners use identity instead of equals. See bug 20193 and 20534.
propsToRemove.replaceAll(String::intern);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The elements in the keys array above are obtained from an ExportedPreferences, which is a subclass of EclipsePreference and therefore has its keys already interned (unless somebody extends this internl class and changes the method to store elements, but those that do that should take care of interning themself).

On the other hand globalNode is just a IEclipsePreferences node from the tree and because Clients may implement this interface, it can be an arbitrary implementation. Therefore interning propsToRemove can only be skipped if the node is of a EclipsePreferences subclass.

In general I would call the listeners that rely on string identity comparison badly implemented.

Copy link

Test Results

   24 files  ±0     24 suites  ±0   10m 53s ⏱️ -33s
2 150 tests ±0  2 105 ✅ ±0  45 💤 ±0  0 ❌ ±0 
2 194 runs  ±0  2 149 ✅ ±0  45 💤 ±0  0 ❌ ±0 

Results for commit b8b93ac. ± Comparison against base commit 9eae0f7.

@HannesWell HannesWell merged commit 11e9f23 into eclipse-equinox:master Dec 25, 2023
23 of 24 checks passed
@HannesWell HannesWell deleted the remove-unncessary-intern branch December 25, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant