Query: Avoid copying the package targets
Change TargetPatternResolver.getTargetsInPackage and the
TargetPatternPreloader to return Collections, rather than
ResolvedTargets instances.
No implementation currently sets the error bit, and no caller requires
it, and the set of filtered targets is always empty.
Make sure that getTargetsMatchingPatternImpl uses a Set to avoid
quadratic runtime. While this may cancel out the improvements from this
change, I have some follow-up changes which use the result and don't
require a Set implementation. I missed this regression because I was
testing it with the additional changes, not independently.
PiperOrigin-RevId: 249243165
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
index be65076..02a9985 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
@@ -474,9 +474,7 @@
}
callback.process(
- resolver
- .getTargetsInPackage(getOriginalPattern(), packageIdentifier, rulesOnly)
- .getTargets());
+ resolver.getTargetsInPackage(getOriginalPattern(), packageIdentifier, rulesOnly));
}
@Override