aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/cache
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-07-06 10:16:01 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-07-07 08:35:42 +0000
commite0e76fd8a60b37dc92c9e3a1b31996a19a71229d (patch)
treecffb19c10338ecacabec4acaf8cfa41bbc6cd8ab /src/main/java/com/google/devtools/build/lib/actions/cache
parentbf2e4ee428b72d6d81f1be11666df458e877f074 (diff)
Micro-optimizations to Digest.fromMetadata():
Don't encode paths as UTF-8 to md5sum them (the map keys are Strings derived from Paths, for which Fingerprint.addPath() takes the same shortcut). Remove defensive copy from the constructor (which did not need to be public). Remove redundant call to Fingerprint.reset(). -- MOS_MIGRATED_REVID=126682477
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/cache')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/cache/Digest.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/Digest.java b/src/main/java/com/google/devtools/build/lib/actions/cache/Digest.java
index 01cf7e1833..c5653ac8fa 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/cache/Digest.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/cache/Digest.java
@@ -13,9 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.actions.cache;
-import com.google.common.annotations.VisibleForTesting;
import com.google.devtools.build.lib.util.Fingerprint;
-import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.VarInt;
import java.io.IOException;
@@ -46,10 +44,8 @@ public class Digest {
* Construct the digest from the given bytes.
* @param digest an MD5 digest. Must be sized properly.
*/
- @VisibleForTesting
- Digest(byte[] digest) {
- Preconditions.checkState(digest.length == MD5_SIZE);
- this.digest = digest.clone();
+ private Digest(byte[] digest) {
+ this.digest = digest;
}
/**
@@ -88,7 +84,6 @@ public class Digest {
Fingerprint fp = new Fingerprint();
for (Map.Entry<String, Metadata> entry : mdMap.entrySet()) {
xorWith(result, getDigest(fp, entry.getKey(), entry.getValue()));
- fp.reset();
}
return new Digest(result);
}
@@ -116,7 +111,7 @@ public class Digest {
}
private static byte[] getDigest(Fingerprint fp, String execPath, Metadata md) {
- fp.addString(execPath);
+ fp.addStringLatin1(execPath);
if (md == null) {
// Move along, nothing to see here.