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

perf(external_link): optimized regexp #4440

Merged
merged 1 commit into from Jul 25, 2020

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Jul 25, 2020

What does it do?

How to test

git clone -b external-link-regexp-perf https://github.com/sukkaw/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@SukkaW SukkaW requested a review from a team July 25, 2020 08:38
@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 98.237% when pulling 5aecc10 on SukkaW:external-link-regexp-perf into 9076422 on hexojs:master.

@SukkaW SukkaW mentioned this pull request Jul 25, 2020
22 tasks
Comment on lines +5 to +8
const rATag = /<a(?:\s+?|\s+?[^<>]+\s+?)?href=["']([^<>"']+)["'][^<>]*>/gi;
const rTargetAttr = /target=/i;
const rRelAttr = /rel=/i;
const rRelStrAttr = /rel=["']([^<>"']*)["']/i;
Copy link
Member Author

Choose a reason for hiding this comment

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

  • Optimized rATag results in 20% less steps during regex matching
  • Cache regexp when hexo is loaded

@SukkaW SukkaW merged commit a29d609 into hexojs:master Jul 25, 2020
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

3 participants