perf($interpolate): optimize value stringification

previously we stringified numbers via toJson which was expensive, I optimized
the code so that toJson is invoked only if really necessary

Closes #7501
This commit is contained in:
Igor Minar
2014-05-17 16:04:37 -07:00
parent de1461da78
commit 9d4fa33e35

View File

@@ -178,10 +178,24 @@ function $InterpolateProvider() {
} else {
part = $sce.valueOf(part);
}
if (part === null || isUndefined(part)) {
if (part == null) { // null || undefined
part = '';
} else if (typeof part != 'string') {
part = toJson(part);
} else {
switch (typeof part) {
case 'string':
{
break;
}
case 'number':
{
part = '' + part;
break;
}
default:
{
part = toJson(part);
}
}
}
}
concat[i] = part;