code cleanup
Peter Jeremy
PeterJeremy at optushome.com.au
Fri Apr 30 02:42:39 PDT 2004
On Thu, 2004-Apr-29 14:55:30 -0400, Brian Fundakowski Feldman wrote:
>For what it's worth, I don't think it is good to hide things as much as
>FOREACH_PROC_IN_SYSTEM() -- this specific instance -- does, but grep is not
>a good tool for a tree as large as FreeBSD's. Try using cscope instead.
My personal favourite is id-utils. It is much faster to rebuild its
database and the database is an order of magnitude smaller (times are
with pre-loaded disk cache on a 4.x /usr/src/sys & system):
server# time mkid
3.514u 0.304s 0:03.83 99.4% 61+14307k 0+44io 0pf+0w
server# time cscope -qRb
13.185u 1.587s 0:15.16 97.3% 225+1449k 0+2347io 0pf+0w
server# ls -l ID cscope.*
-rw-r--r-- 1 root wheel 5578214 Apr 30 19:13 ID
-rw-r--r-- 1 root wheel 4813824 Apr 30 19:14 cscope.in.out
-rw-r--r-- 1 root wheel 33824567 Apr 30 19:14 cscope.out
-rw-r--r-- 1 root wheel 26077716 Apr 30 19:14 cscope.po.out
server#
It saves space by just storing a bit-array of filenames vs identifier
names and using a builtin grep to pick lines out of the files. It
can parse a variety of languages but doesn't distinguish definitions,
declarations or references. On the plus side, it can search by
numeric value, independent of the base (it knows 10, 012, 00012, 0x0a
etc are all equivalent).
My favourite is "less -p `lid IDENTIFIER`" to browse code that includes
references to IDENTIFIER.
--
Peter Jeremy
More information about the freebsd-current
mailing list