aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java
index 9d9cf87ded..74f1fa89a2 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java
@@ -819,15 +819,21 @@ public final class UnixGlob {
}
boolean childIsDir = (type == Dirent.Type.DIRECTORY);
String text = dent.getName();
- Path child = base.getChild(text);
+ // Optimize allocations for the case where the pattern doesn't match the dirent.
+ Path child = null;
if (isRecursivePattern) {
// Recurse without shifting the pattern.
if (childIsDir) {
+ child = base.getChild(text);
context.queueGlob(child, childIsDir, idx);
}
}
if (matches(pattern, text, cache)) {
+ if (child == null) {
+ child = base.getChild(text);
+ }
+
// Recurse and consume one segment of the pattern.
if (childIsDir) {
context.queueGlob(child, childIsDir, idx + 1);