diff options
author | Googler <noreply@google.com> | 2018-05-03 14:57:27 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-03 14:59:11 -0700 |
commit | 36bc96e2e645dec2eca9a8f4174f9ed6b351df51 (patch) | |
tree | 85d3c682d726f3cd455866dee4b426c0a3de6033 /src/main/java | |
parent | f39226cb2a489753ddccb06078cafe1e646b2ef1 (diff) |
Use com.google.common.cache instead of MapMaker.
PiperOrigin-RevId: 195316047
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetStore.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetStore.java b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetStore.java index d4f03de4d7..52d7769a2c 100644 --- a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetStore.java +++ b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetStore.java @@ -15,8 +15,9 @@ package com.google.devtools.build.lib.collect.nestedset; import com.google.auto.value.AutoValue; import com.google.common.annotations.VisibleForTesting; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableList; -import com.google.common.collect.MapMaker; import com.google.common.hash.Hashing; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -30,7 +31,6 @@ import com.google.protobuf.CodedInputStream; import com.google.protobuf.CodedOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; @@ -92,18 +92,18 @@ public class NestedSetStore { /** An in-memory cache for fingerprint <-> NestedSet associations. */ private static class NestedSetCache { - private final Map<ByteString, Object[]> fingerprintToContents = - new MapMaker() + private final Cache<ByteString, Object[]> fingerprintToContents = + CacheBuilder.newBuilder() .concurrencyLevel(SerializationConstants.DESERIALIZATION_POOL_SIZE) .weakValues() - .makeMap(); + .build(); /** Object/Object[] contents to fingerprint. Maintained for fast fingerprinting. */ - private final Map<Object[], FingerprintComputationResult> contentsToFingerprint = - new MapMaker() + private final Cache<Object[], FingerprintComputationResult> contentsToFingerprint = + CacheBuilder.newBuilder() .concurrencyLevel(SerializationConstants.DESERIALIZATION_POOL_SIZE) .weakKeys() - .makeMap(); + .build(); /** * Returns the NestedSet contents associated with the given fingerprint. Returns null if the @@ -111,7 +111,7 @@ public class NestedSetStore { */ @Nullable public Object[] contentsForFingerprint(ByteString fingerprint) { - return fingerprintToContents.get(fingerprint); + return fingerprintToContents.getIfPresent(fingerprint); } /** @@ -120,7 +120,7 @@ public class NestedSetStore { */ @Nullable public FingerprintComputationResult fingerprintForContents(Object[] contents) { - return contentsToFingerprint.get(contents); + return contentsToFingerprint.getIfPresent(contents); } /** Associates the provided fingerprint and NestedSet contents. */ |