Create less garbage in lookupRelative(). The check whether a relative include
breaks out of the package path triggers rarely and so we should only check if
we actually find a file that we'd otherwise be ok to include.
RELNOTES: None.
@@ -357,6 +357,10 @@ public class LegacyIncludeScanner implements IncludeScanner {
return null;
}
PathFragment name = inclusion.pathFragment;
+ PathFragment execPath = includer.getExecPath().getParentDirectory().getRelative(name);
+ if (!isFile(execPath, name, includer.isSourceArtifact(), legalOutputFiles.keySet())) {
+ return null;
+ }
PathFragment parentDirectory = includer.getRootRelativePath().getParentDirectory();
PathFragment rootRelativePath = parentDirectory.getRelative(name);
if (rootRelativePath.containsUplevelReferences()) {
@@ -365,10 +369,6 @@ public class LegacyIncludeScanner implements IncludeScanner {
// directory names there are in it.
return null;
}
- PathFragment execPath = includer.getExecPath().getParentDirectory().getRelative(name);
- if (!isFile(execPath, name, includer.isSourceArtifact(), legalOutputFiles.keySet())) {
- return null;
- }
if (legalOutputFiles.containsKey(execPath)) {
return legalOutputFiles.get(execPath);
}
