Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9d4fa33

Browse files
committed
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
1 parent de1461d commit 9d4fa33

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/ng/interpolate.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,24 @@ function $InterpolateProvider() {
178178
} else {
179179
part = $sce.valueOf(part);
180180
}
181-
if (part === null || isUndefined(part)) {
181+
if (part == null) { // null || undefined
182182
part = '';
183-
} else if (typeof part != 'string') {
184-
part = toJson(part);
183+
} else {
184+
switch (typeof part) {
185+
case 'string':
186+
{
187+
break;
188+
}
189+
case 'number':
190+
{
191+
part = '' + part;
192+
break;
193+
}
194+
default:
195+
{
196+
part = toJson(part);
197+
}
198+
}
185199
}
186200
}
187201
concat[i] = part;

0 commit comments

Comments
 (0)