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

refactor(v2): improve regex matching code-block title #3671

Merged
merged 1 commit into from
Nov 2, 2020

Conversation

hong4rc
Copy link
Contributor

@hong4rc hong4rc commented Nov 1, 2020

Motivation

Sort+quick code

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

I create simple benchmark:

const str = 'something include title="...."';

const oldRegex = /title=".*"/;
const newRegex = /(?<=title=").*(?=")/;

const old = (str) => str.match(oldRegex)[0].split('title=')[1].replace(/"+/g, '');
const newF = (str) => str.match(newRegex)[0];

result: two function return same value

  • sort str:
    • old x 2,411,252 ops/sec ±0.38% (90 runs sampled)
    • newF x 12,002,531 ops/sec ±0.44% (92 runs sampled)
  • long str:
    • old x 1,569,985 ops/sec ±0.44% (92 runs sampled)
    • newF x 3,442,088 ops/sec ±0.43% (91 runs sampled)

@hong4rc hong4rc requested a review from slorber as a code owner November 1, 2020 05:23
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 1, 2020
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 64aa063

https://deploy-preview-3671--docusaurus-2.netlify.app

@slorber
Copy link
Collaborator

slorber commented Nov 2, 2020

Thanks, that seems to work fine so let's merge

@slorber slorber added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Nov 2, 2020
@slorber slorber merged commit 3242549 into facebook:master Nov 2, 2020
@slorber slorber changed the title refactor(v2):regex match title refactor(v2): improve regex matching code-block title Nov 2, 2020
@hong4rc hong4rc deleted the patch-1 branch November 2, 2020 16:06
lex111 added a commit to lex111/docusaurus that referenced this pull request Nov 4, 2020
slorber pushed a commit that referenced this pull request Nov 4, 2020
@slorber
Copy link
Collaborator

slorber commented Nov 4, 2020

this was reverted because it does not work on Safari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants