From: Abdelrazak Younes <younes@lyx.org>
To: Marco Costalba <mcostalba@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [QGIT PATCH/RFC]
Date: Thu, 05 Nov 2009 11:37:49 +0100 [thread overview]
Message-ID: <4AF2AAFD.9000309@lyx.org> (raw)
In-Reply-To: <4AF2A69F.1090802@lyx.org>
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.
next prev parent reply other threads:[~2009-11-05 10:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-04 14:56 [QGIT PATCH/RFC] Abdelrazak Younes
2009-11-05 9:41 ` Marco Costalba
2009-11-05 9:50 ` Abdelrazak Younes
2009-11-05 10:13 ` Abdelrazak Younes
2009-11-05 10:19 ` Abdelrazak Younes
2009-11-05 10:37 ` Abdelrazak Younes [this message]
2009-11-05 20:25 ` Marco Costalba
2009-11-05 20:27 ` Marco Costalba
2009-11-06 8:15 ` Abdelrazak Younes
2009-11-06 8:16 ` Abdelrazak Younes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AF2AAFD.9000309@lyx.org \
--to=younes@lyx.org \
--cc=git@vger.kernel.org \
--cc=mcostalba@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.