mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27: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'
|
||||
|
||||
const charCodeOfDot = '.'.charCodeAt(0)
|
||||
const reEscapeChar = /\\(\\)?/g
|
||||
const reLeadingDot = /^\./
|
||||
const rePropName = RegExp(
|
||||
// Match anything that isn't a dot or bracket.
|
||||
'[^.[\\]]+' + '|' +
|
||||
@@ -25,7 +25,7 @@ const rePropName = RegExp(
|
||||
*/
|
||||
const stringToPath = memoizeCapped((string) => {
|
||||
const result = []
|
||||
if (reLeadingDot.test(string)) {
|
||||
if (string.charCodeAt(0) === charCodeOfDot) {
|
||||
result.push('')
|
||||
}
|
||||
string.replace(rePropName, (match, expression, quote, subString) => {
|
||||
|
||||
Reference in New Issue
Block a user