Re: [QGIT PATCH/RFC]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Abdelrazak Younes wrote:
 Abdelrazak Younes wrote:
> Marco Costalba wrote:
>>
>>> uint qHash(const ShaString& s) { // fast path, called 6-7 times
>>> per revision
>>>
>>>
>>
>> Function:
>>
>> uint qHash(const QByteArray&);
>>
>> is already defined in the Qt Core libraries, so I have a link
>> error with your patch.
>>
>
> By the way, this function of yours is not used anywhere AFAICS.

 Ok, now I understand that this is used by QHash, sorry.

 I have gcc-4.4.1 so maybe that's the reason why linking works in my
 case. But I don't which version of the qhash() function does take
 precedence...

FYI I just verified that your version does take precedence over the Qt one.

Anyway, if you like the patch, we could just inherit from QByteArray instead of typedef it so that it links with your system.

Out of curiosity I just had a look at the two versions, yours:

********************************
// definition of an optimized sha hash function
static inline uint hexVal(const uchar* ch) {
   return (*ch < 64 ? *ch - 48 : *ch - 87);
}

uint qHash(const ShaString& s) { // fast path, called 6-7 times per revision

   const uchar* ch = reinterpret_cast<const uchar*>(s.data());

   return (hexVal(ch ) << 24)
       + (hexVal(ch + 2) << 20)
       + (hexVal(ch + 4) << 16)
       + (hexVal(ch + 6) << 12)
       + (hexVal(ch + 8) << 8)
       + (hexVal(ch + 10) << 4)
       + hexVal(ch + 12);
}
********************************

And Qt's version:

********************************
static uint hash(const uchar *p, int n)
{
   uint h = 0;
   uint g;

   while (n--) {
       h = (h << 4) + *p++;
       if ((g = (h & 0xf0000000)) != 0)
           h ^= g >> 23;
       h &= ~g;
   }
   return h;
}

uint qHash(const QBitArray &bitArray)
{
   int m = bitArray.d.size() - 1;
uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), qMax(0, m));

   // deal with the last 0 to 7 bits manually, because we can't trust that
   // the padding is initialized to 0 in bitArray.d
   int n = bitArray.size();
   if (n & 0x7)
       result = ((result << 4) + bitArray.d.at(m)) & ((1 << n) - 1);
   return result;
}

********************************

I recompiled qgit with the Qt version and I didn't notice any performance problem with a big repo (Qt).

Just tell me if this is not interesting to you and I'll shut up :-)

Abdel.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]