Skip to content

Commit 241632a

Browse files
committed
feat(code size): make assertionsEnabled() statically computable by dart2js
Our existing implementation prevented dart2js from statically deducing the return value. This fix does not yet result in better tree-shaking due to the following dart2js bugs: dart-lang/sdk#24354 dart-lang/sdk#24355 Closes angular#4198
1 parent 06f0d6c commit 241632a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

modules/angular2/src/core/facade/lang.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,11 @@ bool isJsObject(o) {
243243
return false;
244244
}
245245

246-
var _assertionsEnabled = null;
247246
bool assertionsEnabled() {
248-
if (_assertionsEnabled == null) {
249-
try {
250-
assert(false);
251-
_assertionsEnabled = false;
252-
} catch (e) {
253-
_assertionsEnabled = true;
254-
}
255-
}
256-
return _assertionsEnabled;
247+
// TODO(yjbanov): verify that this is inlined after https://github.com/dart-lang/sdk/issues/24355
248+
bool k = false;
249+
assert((k = true));
250+
return k;
257251
}
258252

259253
// Can't be all uppercase as our transpiler would think it is a special directive...

0 commit comments

Comments
 (0)