ntdll: rtlstr.c: Implement checking for control characters inRtlIsTextUnicode [try 2]

Dan Kegel dank at kegel.com
Fri Jun 20 07:29:36 CDT 2008


On Fri, Jun 20, 2008 at 12:23 AM, Rolf Kalbermatter
<rolf.kalbermatter at citeng.com> wrote:
> But personally I feel about the use
> of a switch statement in such a case a bit "overdone". It's not so much
> a selection of operations based on a variable as much more a clear
> conditional expression

I was going for maximally concise and beautiful.  A long conditional
is fine, too.

> I would normally go myself to great
> lengths to avoid a goto as I feel bad about the use of them :-)

Me, too, except in wine and the kernel, where the language
is missing a construct (e.g. C needs a more powerful break),
and sometimes in error handling.

> The fact that s[i] would seem to be evaluated 4 times might look bad
> but should be no problem for nowadays optimizing compilers to create
> similar code as what a switch statement would produce and could be

I looked -- oddly, the switch seems to produce smaller code.
Performance probably doesn't matter in this function, though.

> also avoided by an incremented character pointer instead of the loop
> counter i, which might be even more optimal.

Modern compilers like array indices more than they like pointers,
believe it or not.

And premature optimization is the root of all evil; we should
probably go for the most concise and readable code first,
and avoid inefficiency second.  (So it's ok to hoist the endian
check out of the loop, even though that's an optimization,
because to me it makes the code more natural...)

This is way more discussion of coding than we normally should
ever have about a patch.  I'll shut up now :-)
- Dan



More information about the wine-devel mailing list