[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Review Request: Fix sanitization of dbus path in KMainWindow
From:       Thomas =?utf-8?q?L=C3=BCbking?= <thomas.luebking () web ! de>
Date:       2009-08-18 4:38:00
Message-ID: 200908180638.01155.thomas.luebking () web ! de
[Download RAW message or body]

Am Tuesday 18 August 2009 schrieb Matthew Woehlke:
> Thomas Lübking wrote:
> > static inline bool isIdentifier(char c)
> > {  // the order btw is [a-zA-Z_0-9]
> >     return (c > 96 && c < 123) || (c > 64 && c < 91) ||
> >                c == '_' || (c > 47 && c < 58);
> > }
> 
> ...did I mention yet I think this should be in QChar? :-)
yupp.

> even). How about this? (Mind the broken line-wrapping.)
actually the code included an offense (scnr)

gcc should be smart enough to optimize "a >= b" to "a > b-1" if b is const and 
> 0 at compile time and a and b are POD, so:
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= 
'0' && c <= '9');
should do equal (and is at least less typo prone and more readable)

QChar::toAscii() on the other hand invokes QTextCodec and if 
QString::toAscii() isn't a dumb for(;;) loop across QString[i] you can 
probably really save some cycles here by operating on the bytearray
(given length() and the data() pointer are inline functions one can however 
savely spare those extra assumptions =D )

Regards,
Thomas

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic