[mercury-users] Switching on strings

Michael Day mikeday at yeslogic.com
Thu Jul 24 11:43:35 AEST 2003


> Looking at compiler/switch_gen.m, dense switches on ints, chars and enums are
> by index into a jump table, unless the arms of the switch are
> construction unifications with constants, in which case a lookup table
> is used.
> 
> Switches on DU types is by if-then-else chain, dense jump table, or
> binary search.
> 
> Switches on strings are by hash table.

Awesome :)

(A nice clear cut case where Mercury code can be far shorter and more
intelligible than the corresponding C code, without sacrificing
efficiency).

Michael

-- 
YesLogic Prince prints XML!
http://yeslogic.com

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list