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: https://github.com/dart-lang/sdk/issues/24354 https://github.com/dart-lang/sdk/issues/24355 Closes #4198
This commit is contained in:
parent
06f0d6c046
commit
241632aaa1
|
@ -243,17 +243,11 @@ bool isJsObject(o) {
|
|||
return false;
|
||||
}
|
||||
|
||||
var _assertionsEnabled = null;
|
||||
bool assertionsEnabled() {
|
||||
if (_assertionsEnabled == null) {
|
||||
try {
|
||||
assert(false);
|
||||
_assertionsEnabled = false;
|
||||
} catch (e) {
|
||||
_assertionsEnabled = true;
|
||||
}
|
||||
}
|
||||
return _assertionsEnabled;
|
||||
// TODO(yjbanov): verify that this is inlined after https://github.com/dart-lang/sdk/issues/24355
|
||||
bool k = false;
|
||||
assert((k = true));
|
||||
return k;
|
||||
}
|
||||
|
||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||
|
|
Loading…
Reference in New Issue