wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

Improve dot dir filter in find_file_scanner #356

Closed zdave closed 5 years ago

zdave commented 5 years ago

Prune dot dirs, rather than walking through them and ignoring all the files.

wincent commented 5 years ago

Awesome, great idea, although the behavior I think is not exactly equivalent. If I understand it correctly, -o has very low precedence, so:

# Original version:
# Equivalent to: (type is file) and (not in a dot directory)
find -L . -type f -not -path '*/.*/*'

# New version:
# Equivalent to: (type is file) or (name starts with dot; abort)
find -L . -mindepth 1 -type f -o -name '.*' -prune > /tmp/b

In other words, I think the new version might return directory names too (specifically, ones starting with a dot) but it is only supposed to return file names.

Does that analysis sound right to you?

zdave commented 5 years ago

I believe the new version is equivalent; I tested it on a few directories with a bunch of dot files/dirs in and the output was the same. The reason it doesn't print directories is because the -print0 is in the -type f branch of the or.

wincent commented 5 years ago

Ah got it. That makes sense.

I tested this on a directory with 133,751 eligible files in it:

Both return the same number of files (and the same files). The -prune version runs in about 1.5s on average, the other in about 2s on average.