On Thu, 9 Jul 2009, Linus Torvalds wrote:
So we'd need to do the whole "copy name and add '/' at the end" thing. But
the upside would then be that after that, we'd not need any looping to
find the right ce. So it might be the right thing to do despite the
extra copy.
Naah. I did the numbers. For any normal repository, the 'loop' is going to
hit exactly once. Trying to be smarter about the initial binary search
isn't going to help, and copying the pathname around is only going to
hurt.
In the Linux repo, there's a small handful of cases like this, eg
- "arch/x86/vdso32"
arch/x86/vdso/vdso32-setup.c
arch/x86/vdso/vdso32.S
arch/x86/vdso/vdsp32/
- "drivers/scsi/megaraid"
drivers/scsi/megaraid.c
drivers/scsi/megaraid.h
drivers/scsi/megaraid/
- "include/linux/i2c"
include/linux/i2c-algo-bit.h
include/linux/i2c-algo-pca.h
include/linux/i2c-algo-pcf.h
include/linux/i2c-dev.h
include/linux/i2c-gpio.h
include/linux/i2c-id.h
include/linux/i2c-ocores.h
include/linux/i2c-pca-platform.h
include/linux/i2c-pnx.h
include/linux/i2c-pxa.h
include/linux/i2c.h
include/linux/i2c/
etc (for a total of 45 cases in the whole kernel, if I did my script
right), where we'd loop a few times. But we'd spend more effort trying to
avoid looping than we spend now on the loop.
Linus