On Sat, Jan 25, 2014 at 03:27:44AM +0100, Jann Horn wrote: > replaced a call to isxdigit and comparisons with an array lookup > --- > apt-pkg/contrib/strutl.cc | 41 ++++++++++++++++++++++++----------------- > 1 file changed, 24 insertions(+), 17 deletions(-) It's half the improvement, so I am tempted to say yes for this one, but move the lookup table into the fold-block (the /*{{{*/ and /*}}}*/ are explicit foldmarkers for vim) of the Hex2Num method. Maybe even move it into the function itself, should generate the same code in the end, but the compiler has the better chance of knowning that no other function will access it. In the same ballpark: Add a unlikely() around the 99-error condition, so that compiler and humans know that this really shouldn't happen in practice and can optimize for it (not that anyone would notice). It's clear if you think about it for a moment, but having comments like // 0-9, // a-f, //A-F at the table wouldn't hurt. It's a rather simple function, but if you could add some tests for it to test/libapt/strutil_test.cc I would be happy. Best regards David Kalnischkies
Attachment:
signature.asc
Description: Digital signature