Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Extended globbing seems to have become much slower in recent versions of Zsh
On Mar 4, 2:22pm, Jesper Nygards wrote:
}
} I don't know if this is relevant, but I have some more findings. I wanted
} to know which sub directory was contributing the most to the amount of time
} taken to process the root directory. I then realized that the sum of the
} time it took to process each sub directory separately was much lower than
} processing the whole root directory at once. [...]
} So obviously the processing time is not linear with the number
} of files.
Since exclusions are applied after globbing is completed, the processing
time for exclusions is proportional to the sum of the lengths of all the
file paths found by the recursive glob. If you glob individual sub-
directories, you're not excluding based on the names of the container
directories.
E.g. you should find that
x=(**/*)
y=(${x:#(|*/)(build|target|node|node_modules|.idea|*.min.js|*.iml|TAGS)(|/*))
takes about the same amount of time as your **/*~pat formulation, and
x=(**/*(:t))
y=(${x:#(|*/)(build|target|node|node_modules|.idea|*.min.js|*.iml|TAGS)(|/*))
takes about the same amount of time as your loop over subdirs.
I still don't see a reason why pattern matching would have slowed down.
On the other hand, your pattern could be a lot more precise. You have it
starting with (|*/) and ending with (|/*) which means that you do want to
exclude some directories, but obviously not all of the strings in the
middle are directory names. If I were to guess that the directory names
are build, target, node, and node_modules, then things might go a lot
faster if you used
**/^(.idea|*.min.js|*.iml|TAGS)~(|*/)(build|target|node|node_modules)(|/*)
and even faster with
skipdirs() { reply=( ${REPLY%((build|target|node|node_modules)(|/*)} ) }
**/^(.idea|*.min.js|*.iml|TAGS)(+skipdirs)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author