[cfe-commits] [libcxxabi] r137469 - in /libcxxabi/trunk: src/cxa_demangle.cpp test/test_demangle.cpp

Howard Hinnant hhinnant at apple.com
Fri Aug 12 10:58:53 PDT 2011


On Aug 12, 2011, at 1:47 PM, Jonathan Turner wrote:

> 
> On Aug 12, 2011, at 10:33 AM, Howard Hinnant wrote:
> 
>> Author: hhinnant
>> Date: Fri Aug 12 12:33:10 2011
>> New Revision: 137469
>> +                char* t = f;
>> +                *t++ = 'a';
>> +                *t++ = 'u';
>> +                *t++ = 't';
>> +                *t++ = 'o';
>> +                *t++ = ' ';
> 
> Silly question, but why not use a memcpy type operation here instead of manually setting each character?  There may be a perfectly good reason to do it this way, but it took me a sec to read what it was doing.

The quoted code is a copy/paste from another function.  And I believe an earlier function did call memcpy (or actually strncpy).  At the time I moved from strncpy (for short strings only) I made a judgement, backed up by measuring, that I could get a *little bit* faster by manually dealing with short strings.

The current state of cxa_demangle.cpp isn't perfectly consistent in this regard.  In some places we should probably use strncpy instead of the manual placement, and vice-versa.  The performance difference isn't dramatic.  But at the time I was motivated by a few percent differences.

Howard




More information about the cfe-commits mailing list