Skip to content

Commit

Permalink
Use Iterables.concat() instead of combining into a new set.
Browse files Browse the repository at this point in the history
	Change on 2016/09/22 by kstanger <kstanger@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133991973
  • Loading branch information
kstanger authored and Keith Stanger committed Sep 23, 2016
1 parent 973878f commit fa4d2e3
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -43,7 +43,6 @@
import com.google.devtools.j2objc.util.TypeUtil; import com.google.devtools.j2objc.util.TypeUtil;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
Expand Down Expand Up @@ -146,9 +145,7 @@ private void collectMethods(DeclaredType type) {
private void fixNewMethods(String signature) { private void fixNewMethods(String signature) {
Set<ExecutablePair> existingMethods = this.existingMethods.get(signature); Set<ExecutablePair> existingMethods = this.existingMethods.get(signature);
Set<ExecutablePair> newMethods = this.newMethods.get(signature); Set<ExecutablePair> newMethods = this.newMethods.get(signature);
Set<ExecutablePair> allMethods = new LinkedHashSet<>(); Iterable<ExecutablePair> allMethods = Iterables.concat(existingMethods, newMethods);
allMethods.addAll(existingMethods);
allMethods.addAll(newMethods);
ExecutablePair first = allMethods.iterator().next(); ExecutablePair first = allMethods.iterator().next();
String mainSelector = nameTable.getMethodSelector(first.elem); String mainSelector = nameTable.getMethodSelector(first.elem);
ExecutablePair impl = resolveImplementation(allMethods); ExecutablePair impl = resolveImplementation(allMethods);
Expand All @@ -175,7 +172,7 @@ private void fixNewMethods(String signature) {
} }
} }


private ExecutablePair resolveImplementation(Set<ExecutablePair> allMethods) { private ExecutablePair resolveImplementation(Iterable<ExecutablePair> allMethods) {
ExecutablePair impl = null; ExecutablePair impl = null;
for (ExecutablePair method : allMethods) { for (ExecutablePair method : allMethods) {
if (takesPrecedence(method, impl)) { if (takesPrecedence(method, impl)) {
Expand Down

0 comments on commit fa4d2e3

Please sign in to comment.