Optimize string same() and hitStringKey()

Most strings used as keys are either small or not shared, where the
data pointers cannot be equal.  Of the rest (shared), most could have
been small.

This diff copies small SharedVariant strings, so they don't refer
back to the SharedVariant, and don't need to be enlisted.  Then,
this changes hitStringKey() to not check data pointers, making it
equivalent to StringData::same().  Lastly, hand-write the comparison
loop in StringData::same() so we compare words at a time, and the
loop can be inlined.

Differential Revision: D937233
Esse commit está contido em:
Edwin Smith
2013-08-18 13:49:13 -07:00
commit de Sara Golemon
commit 666fa474ff
3 arquivos alterados com 34 adições e 18 exclusões
+1 -9
Ver Arquivo
@@ -432,15 +432,7 @@ static bool hitStringKey(const HphpArray::Elm& e, const StringData* s,
// it removes an element it always removes the corresponding hash entry.
// Therefore the assertion below must hold.
assert(!HphpArray::isTombstone(e.data.m_type));
if (hash != e.hash()) return false;
auto* s2 = e.key;
if (s2 == s) return true;
const char* data = s->data();
const char* data2 = s2->data();
if (data2 == data) return true;
int len = s->size();
return len == s2->size() && !memcmp(data, data2, len);
return hash == e.hash() && (s == e.key || s->same(e.key));
}
static bool hitIntKey(const HphpArray::Elm& e, int64_t ki) {