Optimize StringPiece hash map

Replace strncmp with memcmp to improve performance.

Signed-off-by: Fredrik Medley <fredrik.medley@gmail.com>
This commit is contained in:
Fredrik Medley 2015-06-12 23:59:12 +02:00
parent 2810ffb2b5
commit 41d2b035e2

View File

@ -76,7 +76,7 @@ struct StringPieceCmp : public hash_compare<StringPiece> {
return MurmurHash2(key.str_, key.len_);
}
bool operator()(const StringPiece& a, const StringPiece& b) const {
int cmp = strncmp(a.str_, b.str_, min(a.len_, b.len_));
int cmp = memcmp(a.str_, b.str_, min(a.len_, b.len_));
if (cmp < 0) {
return true;
} else if (cmp > 0) {