Skip to content

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants