spencertipping/cd — pull request #12 by vivien (2013-07-22 18:32:31+00:00)
Title: cd-traverse: iterate on cd **pattern by depth

This patch makes the cd_traverse_descendant function iterate by level, instead of full directory trees. This is more fast and convenient with huge file hierarchy, as we rarely want to go very deep.

I have several huge trees (such as kernel repositories), and for instance, cd'ing into ~/projects/tinycc took me 0m1.966s while it now takes 0m0.033s (real time, using the time command).

It also interprets the argument as a pattern, for consistency with cd_traverse_ancestor.

An example of usage with the pattern:

````
$ cd **cc && echo $PWD && cd -
/home/vivien/projects/tinycc

$ cd **/cc && echo $PWD && cd -
/home/vivien/projects/openwrt/tools/ccache

$ cd **/cc$ && echo $PWD && cd -
/home/vivien/projects/cd/.git/objects/cc
````