[futurebasic] Re: [FB] Fast lookups and jumps

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2002 : Group Archive : Group : All Groups

From: Jay <jktr@...>
Date: Wed, 24 Apr 02 02:19:45 -0500
>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
>

Robert,

Nice tweak--much better than what I was playing with. (But then we expect 
that of you. :-)

Is this a tad quicker yet?

dim as ptr   myStringPtr
myStringPtr = @myString$
select myStringPtr.1&` >> ((4 - myStringPtr.0``) << 3)
case _"BD"
case _"LI"
case _"SIMM"
end select

 e-e
 =J= a  y
  "