Skip to content

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

Merged
slorber merged 1 commit into
facebook:masterfrom
hong4rc:patch-1
Nov 2, 2020
Merged

refactor(v2): improve regex matching code-block title#3671
slorber merged 1 commit into
facebook:masterfrom
hong4rc:patch-1

Conversation

@hong4rc

@hong4rc hong4rc commented Nov 1, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 64aa063

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

@slorber

slorber commented Nov 2, 2020

Copy link
Copy Markdown
Collaborator

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

slorber commented Nov 4, 2020

Copy link
Copy Markdown
Collaborator

this was reverted because it does not work on Safari

@hong4rc hong4rc restored the patch-1 branch November 4, 2020 15:15
@lex111 lex111 added this to the v2.0.0-alpha.67 milestone Nov 17, 2020
@hong4rc hong4rc deleted the patch-1 branch December 11, 2020 03:26
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
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.

5 participants