mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-19 23:11:21 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user