|
From: | Bruce Lilly |
Subject: | Re: [Gperf-bugs] Gperf 2.7.2 test file questions |
Date: | Thu, 28 Nov 2002 17:54:11 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2a) Gecko/20020910 |
Bruno Haible wrote:
Bruce Lilly writes:Key position set 1,2,6 will always use the first character of the key. For a key of length 5 only positions 1 and 2 of the key are used, compared to 3 positions used for set 2,4,5. Comparing the two key position sets, it should be clear that 2,4,5 will be better for keys with length 3 or less, that there is no advantage of either set for keys of length 4 or of length 6 or greater, and that 1,2,6 is more efficient only for keys of length 5.On the other hand - if all positions can be chosen small enough (<= minimal keyword length), then there is no switch statement in the generated code, and this makes the code faster in all cases. So this is an argument for trying to choose the positions as small as possible.
Though I haven't looked at it recently, I think the code I submitted makes a final pass through the tentatively selected keys to see if any are redundant and can be eliminated. Beware generalizing: the keyword set a bcdefgh can use position 1. However, note that position 7 can alternatively be used as the sole key position, and will be more efficient than using position 1 for key lengths of 6 or less, as no characters from the key need be used. Lack of a switch statement does not necessarily mean faster code. Best regards, Bruce Lilly
[Prev in Thread] | Current Thread | [Next in Thread] |