From 5ec0761cff6616d71f7a6f0ccf164afd1ca46cd2 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 4 Jan 2024 06:06:21 -0800 Subject: [PATCH] Delete redundant output file conflict logic 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 --- .../com/google/devtools/build/lib/packages/Package.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java index 6f37bb631141cc..2d58cf8eb62f93 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Package.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java @@ -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()) {