[Scummvm-devel] Make class String case insensitive by default?

Oystein Eftevaag oystein at geheb.com
Sun Jul 23 12:40:27 CEST 2006


Not replying to anyone in particular here, but...

'Case insensitive' is a property of a particular comparison, not
of the string. As such, to me, it doesn't make any sense to use a flag,
or a subclass to denote a particular string as case insensitive, at all.

There can easily be situations where a particular string should
be case-insensitively compared to one string, and case-sensitively
compared to another, for example. Changing flags before
each comparison would just be messy and counter-intuitive
(and there's the issue where the two objects to compare
have different flags set, as fingolfin mentioned).

I'd just use two separate functions (as has been suggested
already, I believe). Either make '==' be case insensitive
and add an .equals() function, or the other way around.
Or add .equalsInsensitive() and .equalsSensitive() to
really spell it out.

It makes better semantic sense, and you avoid the (minuscule
though it is) performance loss of branching code.


---
Oystein/Vinterstum




More information about the Scummvm-devel mailing list