Efficient STRing ComPaRes

Doug Gwyn gwyn at smoke.brl.mil
Tue Mar 19 15:20:48 AEST 1991


In article <1991Mar18.142342 at mars.mpr.ca> stone at mars.mpr.ca (Darren Stone) writes:
>Next may have to come some algorithm restructuring (the
>real performance problem!) -- I shouldn't blame poor
>little strcmp() for my design problems!

You might want to consider a trick we used in the MUVES project --
a package named "Nm" provided support for "name pools", each of which
could hold an arbitrary number of strings.  The main point of a name
pool is that each distinct string was assigned a distinct INTEGER
index into the name pool, and it was these INTEGERS that were passed
around, compared, etc. in the application.  Obviously the use of the
integer indices is far more efficient than handling the strings as
character arrays.  If the strings are handled very many times apiece,
the performance tradeoff from putting them into a name pool and
handling the indices instead is a big win.  Contact me if you want
the code for the MUVES "Nm" package (I'll have to include some other
support packages, such as the "Mm" memory management package, and
you'll have to figure out how to adapt the Makefiles to your needs).



More information about the Comp.lang.c mailing list