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

Improve the performance of remove Snap interaction #14516

Merged
merged 3 commits into from
Feb 19, 2023

Conversation

XingGuoZ
Copy link
Contributor

@XingGuoZ XingGuoZ commented Feb 18, 2023

#14515 This commit fixes Issue 14515.
When the Snap Source has 13,000 features,the time of remove Snap Interaction will reduced from 6.5s to 150ms

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @XingGuoZ. Can you please address my suggestions. A bonus would be if you could add a test too.

src/ol/interaction/Snap.js Show resolved Hide resolved
@@ -381,7 +381,8 @@ class Snap extends PointerInteraction {
if (currentMap) {
keys.forEach(unlistenByKey);
keys.length = 0;
features.forEach(this.forEachFeatureRemove_.bind(this));
this.rBush_.clear();
features.forEach(this.unlistenFeatureChange_.bind(this));
Copy link
Member

Choose a reason for hiding this comment

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

You could speed this up even more by getting rid of the new unlistenFeatureChange_ method and this change:

Suggested change
features.forEach(this.unlistenFeatureChange_.bind(this));
Object.values(this.featureChangeListenerKeys_).forEach(unlistenByKey);
this.featureChangeListenerKeys_ = {};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! It has been modified in this way

@XingGuoZ
Copy link
Contributor Author

Thanks for your contribution, @XingGuoZ. Can you please address my suggestions. A bonus would be if you could add a test too.

Just now, I learned about test. Please let me know if there is any problem, thank you!

@github-actions
Copy link

📦 Preview the website for this branch here: https://deploy-preview-14516--ol-site.netlify.app/.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Thanks, @XingGuoZ. I took the liberty to complete the test.

@ahocevar ahocevar merged commit 15f0805 into openlayers:main Feb 19, 2023
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.

None yet

2 participants