Replacing a regex in stringToPath with a quick character code check. (#3308)

This commit is contained in:
John-David Dalton
2018-02-02 16:06:03 -08:00
parent f83197727b
commit 7167a78644

View File

@@ -143,7 +143,6 @@
/** Used to match property names within property paths. */ /** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/, reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** /**
@@ -6727,7 +6726,7 @@
*/ */
var stringToPath = memoizeCapped(function(string) { var stringToPath = memoizeCapped(function(string) {
var result = []; var result = [];
if (reLeadingDot.test(string)) { if (string.charCodeAt(0) === 46 /* . */) {
result.push(''); result.push('');
} }
string.replace(rePropName, function(match, number, quote, subString) { string.replace(rePropName, function(match, number, quote, subString) {