mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Faster testing against first char in stringToPath (to close #3308).
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import memoizeCapped from './memoizeCapped.js'
|
import memoizeCapped from './memoizeCapped.js'
|
||||||
|
|
||||||
|
const charCodeOfDot = '.'.charCodeAt(0)
|
||||||
const reEscapeChar = /\\(\\)?/g
|
const reEscapeChar = /\\(\\)?/g
|
||||||
const reLeadingDot = /^\./
|
|
||||||
const rePropName = RegExp(
|
const rePropName = RegExp(
|
||||||
// Match anything that isn't a dot or bracket.
|
// Match anything that isn't a dot or bracket.
|
||||||
'[^.[\\]]+' + '|' +
|
'[^.[\\]]+' + '|' +
|
||||||
@@ -25,7 +25,7 @@ const rePropName = RegExp(
|
|||||||
*/
|
*/
|
||||||
const stringToPath = memoizeCapped((string) => {
|
const stringToPath = memoizeCapped((string) => {
|
||||||
const result = []
|
const result = []
|
||||||
if (reLeadingDot.test(string)) {
|
if (string.charCodeAt(0) === charCodeOfDot) {
|
||||||
result.push('')
|
result.push('')
|
||||||
}
|
}
|
||||||
string.replace(rePropName, (match, expression, quote, subString) => {
|
string.replace(rePropName, (match, expression, quote, subString) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user