git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [QGIT PATCH/RFC]

From
AYAbdelrazak Younes <younes@lyx.org>
Date
Nov 5, 2009, 10:37 UTC
Message-ID
<4AF2AAFD.9000309@lyx.org>
In-Reply-To
<4AF2A69F.1090802@lyx.org>
Abdelrazak Younes wrote:
Show 23 quoted lines
>  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.
Previous: Abdelrazak YounesNext: Marco Costalba
Message 6 of 10 in “[QGIT PATCH/RFC]”
  1. Abdelrazak Younes, Nov 4, 2009
  2. Marco CostalbaNov 5, 2009
  3. Abdelrazak YounesNov 5, 2009
  4. Abdelrazak YounesNov 5, 2009
  5. Abdelrazak YounesNov 5, 2009
  6. Abdelrazak YounesNov 5, 2009
  7. Marco CostalbaNov 5, 2009
  8. Marco CostalbaNov 5, 2009
  9. Abdelrazak YounesNov 6, 2009
  10. Abdelrazak YounesNov 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.