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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _assertionsEnabled = null;
|
|
||||||
bool assertionsEnabled() {
|
bool assertionsEnabled() {
|
||||||
if (_assertionsEnabled == null) {
|
// TODO(yjbanov): verify that this is inlined after https://github.com/dart-lang/sdk/issues/24355
|
||||||
try {
|
bool k = false;
|
||||||
assert(false);
|
assert((k = true));
|
||||||
_assertionsEnabled = false;
|
return k;
|
||||||
} catch (e) {
|
|
||||||
_assertionsEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _assertionsEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user