[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: prepare vasnprintf for Unicode strings
From: |
Paul Eggert |
Subject: |
Re: prepare vasnprintf for Unicode strings |
Date: |
Tue, 12 Jun 2007 11:44:36 -0700 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> Hey, 'int' is a flexible data type!
I agree, though for this particular example I find the code
easier to read if the test is ordered numerically, and if an
if-then-else expression is used. So, instead of this:
if (flags >= 16)
type = TYPE_U32_STRING;
else if (flags >= 8)
type = TYPE_U16_STRING;
else
type = TYPE_U8_STRING;
I might use something like the following, say.
type = (flags < 8 ? TYPE_U8_STRING
: flags < 16 ? TYPE_U16_STRING
: TYPE_U32_STRING);
Or if you prefer 'int' idioms I might do it this way:
type = TYPE_U8_STRING + (8 <= flags) + (16 <= flags);
as this is faster and smaller on many platforms.
(But this is a very small point of course. To each his own.)
Re: prepare vasnprintf for Unicode strings, Daniel Jacobowitz, 2007/06/11