diff options
author | Googler <noreply@google.com> | 2016-04-14 21:25:55 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2016-04-15 07:37:25 +0000 |
commit | 00d0938f61c0698d0c30a76d1838e2514c9b19f8 (patch) | |
tree | 1740e72f45936bf4fbddfa2081ec1499fa908192 /src/main | |
parent | a0303c14aabe6a8be3ec39d35701b0a1aa44e4c8 (diff) |
Use Iterables.addAll() in SkylarkList.
It is probably more efficient in the common case where the Iterable is a collection. String and list handling in Skylark results in a *lot* of calls to this method, and the use of addAll should reduce the amount of copying and GCing that needs to occur.
An alternative would be to change the underlying type of SkylarkList from ArrayList to LinkedList, which would reduce the copying and GCing due to list concatenation even more. There is probably a downside to that but it is not clear if it is significant.
--
MOS_MIGRATED_REVID=119891128
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java index 60d6754766..5855824bb1 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java @@ -282,9 +282,7 @@ import javax.annotation.Nullable; * Assumes that you already checked for Mutability. */ private void addAllUnsafe(Iterable<? extends E> elements) { - for (E elem : elements) { - contents.add(elem); - } + Iterables.addAll(contents, elements); } @Override |