aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/DataKey.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-07-26 14:29:48 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-07-27 11:14:04 +0000
commit2745f0bafd7d549688480cdee3f021de489c719e (patch)
tree4bc375688e5af969414b1bc3633dec47e8b1f9d0 /src/tools/android/java/com/google/devtools/build/android/DataKey.java
parent3cf21261bf756c937551c7d852dbca5c954fc44f (diff)
Improve resource DataKey serialization perf a bit
Address the TODO about using toString in the TreeMap comparator by using DataKey#compareTo. Also, use the entrySet to iterate K-V pairs instead of calling get(key). Synthetic benchmark w/ 10000 random keys: Before: 260ms to serialize After: 33ms to serialize Less of a difference when there are few keys. -- MOS_MIGRATED_REVID=128469407
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/DataKey.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataKey.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataKey.java b/src/tools/android/java/com/google/devtools/build/android/DataKey.java
index e3a8b9d987..0fbbd1f9ed 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataKey.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataKey.java
@@ -26,7 +26,8 @@ import java.io.OutputStream;
*
* For Assets, it is the asset path from the assets directory.
*/
-public interface DataKey {
+public interface DataKey extends Comparable<DataKey> {
+
/**
* Writes the Key and the value size to a stream.
*
@@ -40,4 +41,14 @@ public interface DataKey {
* Returns a human readable string representation of the key.
*/
String toPrettyString();
+
+ /**
+ * Defines a total ordering on the different key types to assist in compareTo operations.
+ */
+ enum KeyType {
+ ASSET_PATH,
+ FULL_QUALIFIED_NAME
+ }
+
+ KeyType getKeyType();
}