[Lazarus] Easiest way to "case" strings

Flávio Etrusco flavio.etrusco at gmail.com
Sat Mar 21 16:15:05 CET 2009


>>
>> Can anyone say why there is no string case statement in Object Pascal?  I've
>> always wondered about this as sometimes it hard to avoid 10-20 If..then..else
>> if.... statements.
>>
>> Would the compiled code of a string case statement even be any more efficient or
>> is the benefit mostly in code readability?
>
> In the case of strings, it would mostly be code readability. For ordinal
> types, a case statement can be optimized using jump tables.
>
> Michael.

A string case could be optimized with compile-time hashes or something else.

-Flávio




More information about the Lazarus mailing list