Explorar el Código

core: allow hashing of String objects.

legacy
Sam Hocevar sam hace 12 años
padre
commit
46cf14e37c
Se han modificado 2 ficheros con 17 adiciones y 1 borrados
  1. +11
    -1
      src/core/hash.cpp
  2. +6
    -0
      src/lol/core/hash.h

+ 11
- 1
src/core/hash.cpp Ver fichero

@@ -122,7 +122,7 @@ uint32_t Hash<uint64_t>::operator ()(uint64_t x)
return ret ^ 0xffffffffu;
}

uint32_t Hash<char const *>::operator ()(char const *s)
static uint32_t HashCharString(char const *s)
{
uint32_t ret = 0xffffffffu, ch;

@@ -132,5 +132,15 @@ uint32_t Hash<char const *>::operator ()(char const *s)
return ret ^ 0xffffffffu;
}

uint32_t Hash<char const *>::operator ()(char const *s)
{
return HashCharString(s);
}

uint32_t Hash<String>::operator ()(String const &s)
{
return HashCharString(&s[0]);
}

} /* namespace lol */


+ 6
- 0
src/lol/core/hash.h Ver fichero

@@ -37,6 +37,12 @@ public:
uint32_t operator()(char const *x);
};

template<> class Hash<String>
{
public:
uint32_t operator()(String const &s);
};

} /* namespace lol */

#endif // __LOL_HASH_H__


Cargando…
Cancelar
Guardar