diff options
author | shahan <shahan@google.com> | 2018-04-02 13:26:14 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-02 13:27:28 -0700 |
commit | 9012e6f2ddbca2af21f9ae892a9d2fb09841e304 (patch) | |
tree | 5137ee493a3760fe0b30b07b6cf007de3b96d68d /src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java | |
parent | 41f7df715e83ddaf5a75b5738587c9d842ec75b4 (diff) |
Moves the decision to enable memoization from codecs to the top-level invocation.
Also, makes it benign to registerInitialValue when memoization is disabled.
PiperOrigin-RevId: 191338253
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java index 4128092f1e..4ec874b03e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DynamicCodec.java @@ -38,18 +38,11 @@ public class DynamicCodec implements ObjectCodec<Object> { private final Class<?> type; private final Constructor<?> constructor; private final ImmutableSortedMap<Field, Long> offsets; - private final ObjectCodec.MemoizationStrategy strategy; public DynamicCodec(Class<?> type) throws ReflectiveOperationException { - this(type, ObjectCodec.MemoizationStrategy.MEMOIZE_BEFORE); - } - - public DynamicCodec(Class<?> type, ObjectCodec.MemoizationStrategy strategy) - throws ReflectiveOperationException { this.type = type; this.constructor = getConstructor(type); this.offsets = getOffsets(type); - this.strategy = strategy; } @Override @@ -59,7 +52,7 @@ public class DynamicCodec implements ObjectCodec<Object> { @Override public MemoizationStrategy getStrategy() { - return strategy; + return ObjectCodec.MemoizationStrategy.MEMOIZE_BEFORE; } @Override @@ -141,9 +134,7 @@ public class DynamicCodec implements ObjectCodec<Object> { } catch (ReflectiveOperationException e) { throw new SerializationException("Could not instantiate object of type: " + type, e); } - if (strategy.equals(ObjectCodec.MemoizationStrategy.MEMOIZE_BEFORE)) { - context.registerInitialValue(instance); - } + context.registerInitialValue(instance); for (Map.Entry<Field, Long> entry : offsets.entrySet()) { deserializeField(context, codedIn, instance, entry.getKey().getType(), entry.getValue()); } |