Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: >>>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes: > | Andre> On Mon, Mar 11, 2002 at 06:21:03PM +0100, Lars Gullik Bjønnes | Andre> wrote: >>> I felt that the layout lookup became a bit slow with the new layout >>> as string stuff, so I did this patch. Is the added complexity worth >>> it? > | Did you see any evidence of that in gprof? > | Andre> Hm... I doubt that there is a lot of difference when there are | Andre> just 30 items in the vector/map... Do you have any hard | Andre> numbers? > | It looks suspicious, indeed. As Lars points out, everything here | should be in constants and local optimizations. > | Andre> Apart from that I'd rather try to come up with some "really | Andre> fast" 'conststring' class which could improve most of the | Andre> handling of this 'strings used for convenience reasons' stuff, | Andre> both for memory and runtime. > | What would such a class do to be fast?
In the lyxtextclass senario there is little a conststring class could do... comparisons are O(n) on the string anyway. One further optimization, over that patch that I sent, is to use a hash_map if it exists. That would give O(1) lookup. There is also the possiblity of using a "tuning" lists, and list where often used items are moved forward, so that lookup is faster next time the same iterm is wanted, but is still O(n) in the general case. -- Lgb