Universal escaping in KConfigINI: Summary and patch

Oswald Buddenhagen ossi at kde.org
Thu May 24 18:05:30 BST 2007


On Thu, May 24, 2007 at 06:47:41PM +0200, Andreas Hartmetz wrote:
> On Thursday 24 May 2007 11:12:35 Oswald Buddenhagen wrote:
> > also, parsing uppercase hex might be not wrong to avoid surprises.
> >
> Rejecting uppercase is faster.
>
not if it is the last case you check. unless you want the error case to
be fast. ;)

> I was thinking that whoever inserts escape sequences by hand should
> know what s/he is doing beforehand. This is debatable.
> 
i know, but why not.

> The switch blocks are not inelegant, they are really ugly :)
> The use of switch statements was a conscious decision.
> These implementations have the advantage of obviously not having any index out 
> of bounds errors, and I trust the compiler to make a table out of switch 
> statements where possible. The simplistic switch statement should be easy to 
> understand by the compiler so it can optimize well.
> If you are reasonably sure that one of the target compilers won't do this, 
> I'll change it.
> 
no sane compiler will automatically generate an almost-256-entry table
for 16 values. ;) if you used the *low* nibble in toHex it *might*
optimize it, but given that the manual solution is much nicer i would
not take chances.
i see little chance for toChar being optimized, too, but you can look at
the -S output ... but even if, it would be still ugly for almost no
benefit (the bounds checking and indexing will outweight the few
comparisons and arithmetics easily).

> > >      // Strip trailing white-space.
> > > -    while((l>0) &&
> > > -          ((str[l-1] == ' ') || (str[l-1] == '\t') || (str[l-1] == '\r'))) -    {
> > > +    while((l>0) && ((str[l-1] == ' ') || (str[l-1] == '\t') || (str[l-1] == '\r'))) {
> > >          l--;
> > >      }
> >
> > i find it counterproductive that you joined the lines. it's really
> > barely readable now.
> >
> OK... I tend to think that if a statement is too long, it *is* too
> long and the statement needs to be changed if possible, not the
> formatting. Still, no problem to leave it unchanged.
> 
well, i *like* monster statements. they just have to be formatted
sanely. :)

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.




More information about the kde-core-devel mailing list