neovim/neovim — pull request #1043 by splinterofchaos (2014-08-06 23:12:10+00:00)
Title: Enable BFS for :find.

The first commit allows nvim to toggle between DFS and BFS for the `:find` command by running `:set breadthfirst` or `:set nobreadthfirst`. The second just changes the names of variables because calling a "queue" a "stack" makes no sense.

To test it, I went into my root directory and ran
```
/$ time /home/admin/src/neovim/build/bin/nvim -c ':find vim.h | :q'
1.12user 0.76system 0:01.89elapsed 99%CPU (0avgtext+0avgdata 9300maxresident)
0inputs+328outputs (0major+12437minor)pagefaults 0swaps
```

The format got garbled from having run vim through it, but it found `vim.h` in just over a second! In that amount of time, even the linux program find is still reading my `~/.cabal` directory (quite huge).

**Caveats:** I'm not sure my test and `make test` are very comprehensive. I had a segfault to fix on builds that ran through the tests perfectly, and this wouldn't be the first time I broke vim without a test reporting it. I also have been considering disabling `breadthfirst` during certain operations other than `:find`.

Also, the source warned:

> * The search algorithm is depth first. To change this replace the
* stack with a list (don't forget to leave partly searched directories on the
* top of the list).

I don't fully understand the meaning of that. I thought the logic of what to leave on the list or take off was implemented in the calling code of `ff_push()` and `ff_pop()`, so I'd imagine that by just overloading those, I'm done. Assuming that, I edited this comment to reflect the changes.