Skip to content

Conversation

@zhiyuanzmj
Copy link
Contributor

before

const id = 1
const str = '<div flex={ >'+'.'.repeat(30)
const elementRE = /(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|[\{`]([^>]|[\S])*?[\}`]|[^>]*?)*)/g
console.time()
for (const i of Array.from(str.matchAll(elementRE))){
      console.log(i)
}
console.timeEnd()      

It will execute for a few seconds.

after

const id = 1
const str = '<div flex={ >'+'.'.repeat(30)
const elementRE = /(<\w[\w:\.$-]*\s)([\s\S]*)\/?>/g
console.time()
for (const i of Array.from(str.matchAll(elementRE))){
      console.log(i)
}
console.timeEnd()      

improve regular performance
@zhiyuanzmj zhiyuanzmj requested a review from antfu as a code owner September 6, 2023 15:53
@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 82f2a6c
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/64f8a077f95d35000803d7b8
😎 Deploy Preview https://deploy-preview-3088--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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.

2 participants