Avoid creating an array in stringSize.

This commit is contained in:
John-David Dalton
2015-09-15 20:34:11 -07:00
parent 49266dce89
commit f7e05e438e

View File

@@ -1183,9 +1183,14 @@
* @returns {number} Returns the string size.
*/
function stringSize(string) {
return (string && reStrSurrogate.test(string))
? stringToArray(string).length
: string.length;
if (!(string && reStrSurrogate.test(string))) {
return string.length;
}
var result = reStrSymbol.lastIndex = 0;
while (reStrSymbol.test(string)) {
result++;
}
return result;
}
/**