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

Replacing a regex with a quick character check #3308

Closed
wants to merge 1 commit into from
Closed

Replacing a regex with a quick character check #3308

wants to merge 1 commit into from

Conversation

tlhunter
Copy link

@tlhunter tlhunter commented Aug 8, 2017

  • Checking the 0th position of the string should be quicker than a regular expression

* Checking the 0th position of the string should be quicker than a regular expression
@jsf-clabot
Copy link

jsf-clabot commented Aug 8, 2017

CLA assistant check
All committers have signed the CLA.

@@ -25,7 +24,7 @@ const rePropName = RegExp(
*/
const stringToPath = memoizeCapped((string) => {
const result = []
if (reLeadingDot.test(string)) {
if (string.charAt(0) === '.') {
result.push('')
Copy link
Member

Choose a reason for hiding this comment

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

Comparing against the char code would be faster.
Something lile

const codeOfDot = '.'.charCodeAt(0)

Then later

string.charCodeAt(0) === codeOfDot

@jdalton
Copy link
Member

jdalton commented Aug 10, 2017

Closing as inactive.

@lock
Copy link

lock bot commented Dec 26, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 26, 2018
@tlhunter tlhunter deleted the patch-1 branch December 28, 2018 00:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants