Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: pkg/compiler/lib/src/serialization/modelz.dart

Issue 1919143002: Store constant variable initializers in elements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/serialization/modelz.dart
diff --git a/pkg/compiler/lib/src/serialization/modelz.dart b/pkg/compiler/lib/src/serialization/modelz.dart
index 9c346d935b83634ea20b720211b4d32fdf090881..b7f17b3bf7de73ba1457c12e9c696cd98c8f4f76 100644
--- a/pkg/compiler/lib/src/serialization/modelz.dart
+++ b/pkg/compiler/lib/src/serialization/modelz.dart
@@ -1271,6 +1271,7 @@ abstract class FieldElementZ extends DeserializedElementZ
TypedElementMixin,
MemberElementMixin
implements FieldElement {
+ bool _isConst;
ConstantExpression _constant;
FieldElementZ(ObjectDecoder decoder) : super(decoder);
@@ -1286,14 +1287,22 @@ abstract class FieldElementZ extends DeserializedElementZ
@override
bool get isFinal => _decoder.getBool(Key.IS_FINAL);
+ void _ensureConstant() {
+ if (_isConst == null) {
+ _isConst = _decoder.getBool(Key.IS_CONST);
+ _constant = _decoder.getConstant(Key.CONSTANT, isOptional: true);
+ }
+ }
+
@override
- bool get isConst => _decoder.getBool(Key.IS_CONST);
+ bool get isConst {
+ _ensureConstant();
+ return _isConst;
+ }
@override
ConstantExpression get constant {
- if (isConst && _constant == null) {
- _constant = _decoder.getConstant(Key.CONSTANT);
- }
+ _ensureConstant();
return _constant;
}
« no previous file with comments | « pkg/compiler/lib/src/serialization/element_serialization.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698