From 7167a78644120a72863b32a414bac84ac6cfaa61 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 2 Feb 2018 16:06:03 -0800 Subject: [PATCH] Replacing a regex in `stringToPath` with a quick character code check. (#3308) --- lodash.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index bdc201451..0b7579d6d 100644 --- a/lodash.js +++ b/lodash.js @@ -143,7 +143,6 @@ /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** @@ -6727,7 +6726,7 @@ */ var stringToPath = memoizeCapped(function(string) { var result = []; - if (reLeadingDot.test(string)) { + if (string.charCodeAt(0) === 46 /* . */) { result.push(''); } string.replace(rePropName, function(match, number, quote, subString) {