-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
refactor(open_graph): drop cheerio and use regex #3680
Conversation
For regex, I have test those pattern with regex101 to match this post:
6491 steps, 9 matches, ~3ms: https://regex101.com/r/N1Rv9w/1
8858 steps, 9 matches, ~5ms: https://regex101.com/r/N1Rv9w/2
6527 steps, 9 matches, ~4ms: https://regex101.com/r/N1Rv9w/3
4313 steps, 9 matched, ~3ms: https://regex101.com/r/N1Rv9w/4
4627 steps, 9 matched, ~4ms: https://regex101.com/r/N1Rv9w/5 Currently in this PR I am using the first one. Update After 4f86dde I am now using the forth one. Update
4573 steps, 9 matched, ~4ms: https://regex101.com/r/N1Rv9w/7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I have update the final benchmark for this PR & #3670
The last benchmark shows this PR increase performance by nearly I will merge this PR and close #3670 then. |
* refactor(open_graph): drop cheerio and use regex * feat(open_graph): faster regex pattern for img tag * refactor(open_graph): eliminate unnecessary checks * feat(open_graph): a new regex which use less steps * test(open_graph): add img with empty src attribute
What does it do?
cheerio is slow and we only use that to parse and list img in post.content. This PR drop cheerio and use regex to do the job.
How to test
Screenshots
913f5be
4f86dde
5c309eb
c11ded4
Pull request tasks