Skip to content

Commit

Permalink
Delete redundant output file conflict logic
Browse files Browse the repository at this point in the history
outputFilePrefixes is a map used to help check whether one OutputFile's name clashes with a directory prefix of another. Since it's updated with info from every OutputFile of a rule passed to checkForConflicts(), there's no need to also update it in addRuleUnchecked().

This is a no-op assuming that no user of Package.Builder calls both addRule() and addRuleUnchecked() -- which is currently the case, and ought to be enforced, perhaps in a follow-up CL.

(Note that the alternative approach, of deleting the map update in checkForConflicts() while leaving it intact in addRuleUnchecked(), is not only less readable, but also incorrect since it doesn't catch conflicts between OutputFiles of the same generating rule.)

Work toward #19922.

PiperOrigin-RevId: 595683434
Change-Id: I8b660807edfa1eef5101fe362ddaed4352e3f684
  • Loading branch information
brandjon authored and copybara-github committed Jan 4, 2024
1 parent 3490df2 commit 5ec0761
Showing 1 changed file with 0 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1553,15 +1553,8 @@ void addEnvironmentGroup(
*/
void addRuleUnchecked(Rule rule) {
Preconditions.checkArgument(rule.getPackage() == pkg);
// Now, modify the package:
for (OutputFile outputFile : rule.getOutputFiles()) {
targets.put(outputFile.getName(), outputFile);
PathFragment outputFileFragment = PathFragment.create(outputFile.getName());
int segmentCount = outputFileFragment.segmentCount();
for (int i = 1; i < segmentCount; i++) {
String prefix = outputFileFragment.subFragment(0, i).toString();
outputFilePrefixes.putIfAbsent(prefix, outputFile);
}
}
targets.put(rule.getName(), rule);
if (rule.containsErrors()) {
Expand Down

0 comments on commit 5ec0761

Please sign in to comment.