[llvm-commits] [llvm] r92884 - /llvm/trunk/lib/Support/StringRef.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 6 18:29:14 PST 2010


On Jan 6, 2010, at 5:09 PM, John McCall wrote:

> Just to drive you insane with trivialities... :)
> 
> On Jan 6, 2010, at 4:51 PM, Douglas Gregor wrote:
>> @@ -51,13 +52,21 @@
>>  size_type m = size();
>>  size_type n = Other.size();
>> 
>> -  SmallVector<unsigned, 32> previous(n+1, 0);
>> -  for (SmallVector<unsigned, 32>::size_type i = 0; i <= n; ++i) 
>> +  unsigned SmallPrevious[32];
>> +  unsigned SmallCurrent[32];
>> +  
>> +  unsigned *previous = SmallPrevious;
>> +  unsigned *current = SmallCurrent;
>> +  if (n + 1 > 32) {
>> +    previous = new unsigned [n+1];
>> +    current = new unsigned [n+1];
>> +  }
>> +  
>> +  for (unsigned i = 0; i <= n; ++i) 
>>    previous[i] = i;
>> 
>> -  SmallVector<unsigned, 32> current(n+1, 0);
>>  for (size_type y = 1; y <= m; ++y) {
>> -    current.assign(n+1, 0);
>> +    std::memset(current, 0, (n + 1) * sizeof(unsigned));
>>    current[0] = y;
>>    for (size_type x = 1; x <= n; ++x) {
>>      if (AllowReplacements) {
> 
> This memset is unnecessary;  the algorithm does not read values from 'current' that have not yet been written for this column.
> 
> Also, you only need one allocation. :)

*grumble, grumble*

	http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100104/093781.html

	- Doug





More information about the llvm-commits mailing list