>I have the need for speed. Does anyone have a >better idea for a jump table to replace a SELECT/CASE >structure? > >What I would like to do is to jump to a certain section >based on the contents of a string. The string will be one >to four characters in length, all capitals. > > Ultimately, I want to see if I can gain >enough speed to warrant some ugly inflexible code. > >SELECT myString$ >CASE "BD" >// do this ... >CASE "LI" >// do this ... >CASE "SIMM" < snip > >END SELECT Case with a string is slow because there are two calls to runtime routines (GETSTRCONST and FBCompareStrings), as shown by this disassembly: CASE "BD" ' +00000014 li r3,0x0B12 ' +00000018 bl GETSTRCONST+0x0004 ' +0000001C li r31,0x0021 ' +00000020 mr r3,r31 ' +00000024 bl FBCompareStrings+0x0004 ' +00000028 mr. r3,r3 ' +0000002C bne _FCOD_1001+0x0048 ' +00000030 b _FCOD_1001+0x004C Convert your string's 1-4 characters to a long, and use underscore constants in the case statements: dim as ptr myStringPtr dim as long myLong, stringLen myStringPtr = @myString$ myLong = 0 stringLen = myStringPtr.nil`` while stringLen stringLen-- myStringPtr++ myLong = (myLong << 8) + myStringPtr.nil`` wend select myLong case _"BD" case _"LI" case _"SIMM" end select Case is now completely inline, and much faster: case _"BD" ' +000000F4 li r3,0x4244 ' +000000F8 lwz r4,0x0020(SP) ' +000000FC cmpw r3,r4 ' +00000100 beq _FCOD_1001+0x011C ' +00000104 b _FCOD_1001+0x0120 Robert P.