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

optimization: speed up Parser#siblingsCorrection #1494

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Feb 18, 2024

Part of #1049

What is the purpose of this PR?

  • Fix bug
  • Fix typo
  • Update specs
  • Add new rule
  • Add new parser
  • Improve or refactor rules
  • Add a new core feature
  • Improve or refactor core features
  • Update documents
  • Others

Description

This PR optimizes Parser#siblingsCorrection in two ways:

  1. Replace O(n) .findLast in .siblingsCorrection with O(1) lookup
    • Labeled as sC in the below chart
  2. In addition to that optimization, sortNumber is also optimized.
    • Labeled as sC + sN in the below chart

Test data: 1500+ options as mentioned in #1049

image
. v4.1.0 v4.1.1 sC sC + sN (this PR)
3rd quartile 5.00 4.50 4.44 4.21
Median 4.97 4.45 4.40 4.16
1st quartile 4.92 4.42 4.39 4.13

As the result, the entire process time on many <option>s is 6.5% shorter compared to v4.1.1.
(4.16 / 4.45 = 0.935)

Checklist

Fill out the checks for the applicable purpose.

@exoego exoego marked this pull request as ready for review February 18, 2024 13:42
@YusukeHirao YusukeHirao merged commit c4149a8 into markuplint:dev Feb 19, 2024
29 checks passed
@YusukeHirao
Copy link
Member

@exoego Thank you!

@exoego exoego deleted the lookup branch February 19, 2024 11:12
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