8000 perf: simplify `DOM.compareDocumentPosition` by zorkow · Pull Request #805 · xmldom/xmldom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf: simplify DOM.compareDocumentPosition #805

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

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

zorkow
Copy link
Contributor
@zorkow zorkow commented Dec 11, 2024

PR contributes a more efficient coding for the compareDocumentPosition method contributed in PR #488
. In detail:

  • Removes the parentChain method and replaces it with a parent chain computation that immediately compares target nodes, thus avoiding unnecessary computations.
  • Uses push and reverse instead of unshift to assemble chains as this is considerably faster.

Copy link
codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.08%. Comparing base (83b01fc) to head (4bf0b41).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #805      +/-   ##
==========================================
+ Coverage   95.06%   95.08%   +0.01%     
==========================================
  Files           8        8              
  Lines        2169     2177       +8     
  Branches      571      571              
==========================================
+ Hits         2062     2070       +8     
  Misses        107      107              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@karfau
Copy link
Member
karfau commented Dec 12, 2024

Thx again, it even looks faster 😉

When you update the branch against the latest master branch, I can merge it.

@karfau karfau changed the title Refactors compareDocumentPosition Method perf: simplify DOM.compareDocumentPosition Dec 12, 2024
@zorkow
Copy link
Contributor Author
zorkow commented Dec 16, 2024

When you update the branch against the latest master branch, I can merge it.

Done.

On a different note: Are you considering moving to ES modules at some point. I did a quick and dirty mockup the other day for the MathJax dev lab, where modules are imported directly from source rather than bundled, and conversion took about ten minutes.

@karfau karfau merged commit 8a371a5 into xmldom:master Dec 16, 2024
38 checks passed
@karfau
Copy link
Member
karfau commented Dec 16, 2024

On a different note: Are you considering moving to ES modules at some point. I did a quick and dirty mockup the other day for the MathJax dev lab, where modules are imported directly from source rather than bundled, and conversion took about ten minutes.

I'm really low on resources regarding this project currently, so I will very likely not be the person to initiate this.
I also guess it would be another breaking change and what to do about still supporting the current ways of using the lib, ... I did not even have the time to fully understand the available options and what it would take.
But if somebody else makes it happen in a way that is possible for me to sustain/maintain I will consider it.
The technical overhaul of this lib is overdue, but my capacity is limited and there are multiple other options out there that might be a better fit for those use cases...

@zorkow zorkow deleted the refactor/comparePosition branch December 16, 2024 11:51
@zorkow
Copy link
Contributor Author
zorkow commented Dec 16, 2024

Thanks for the merge.

I'm really low on resources regarding this project currently, so I will very likely not be the person to initiate this.

I know what you mean. It's not as if I had any free cycles. It would be a shame to see that project die, though, as it really is a lean and effective DOM Implementation. There are many bloated ones around...
Anyway, for maybe my es6 hack will help someone in the future:
https://github.com/Speech-Rule-Engine/xmldom/tree/feature/es6_modules/mjs

As I said quick and dirty, mostly done with a couple of sed scripts.

@karfau karfau added this to the 0.9.7 milestone Jan 19, 2025
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.

2 participants
0