refactor(angular.toJson): use charAt instead of regexp

Provides a performance improvement when serializing to JSON strings.

Closes #4093
This commit is contained in:
Boris Serdyuk 2013-09-21 12:38:09 +04:00 committed by Pete Bacon Darwin
parent e2751292da
commit 6c59e77008

View file

@ -781,7 +781,7 @@ function bind(self, fn) {
function toJsonReplacer(key, value) {
var val = value;
if (/^\$+/.test(key)) {
if (typeof key === 'string' && key.charAt(0) === '$') {
val = undefined;
} else if (isWindow(value)) {
val = '$WINDOW';