Ejemplo n.º 1
0
	size_t operator() (StringRef x) const
	{
		const char * pos = x.data;
		size_t size = x.size;

		const char * end = pos + size;

		size_t res = 0;

		if (size == 0)
			return 0;

		if (size < 8)
		{
			return hashLessThan8(x.data, x.size);
		}

		while (pos + 8 < end)
		{
			UInt64 word = *reinterpret_cast<const UInt64 *>(pos);
			res = intHash64(word ^ res);

			pos += 8;
		}

		UInt64 word = *reinterpret_cast<const UInt64 *>(end - 8);
		res = intHash64(word ^ res);

		return res;
	}
Ejemplo n.º 2
0
    size_t operator() (CompactStringRef x) const
    {
        const char * pos = x.data();
        size_t size = x.size;

        const char * end = pos + size;

        size_t res = 0;

        if (size == 0)
            return 0;

        if (size < 8)
        {
            memcpy(reinterpret_cast<char *>(&res), pos, size);
            return intHash64(res);
        }

        while (pos + 8 < end)
        {
            UInt64 word = *reinterpret_cast<const UInt64 *>(pos);
            res = intHash64(word ^ res);

            pos += 8;
        }

        UInt64 word = *reinterpret_cast<const UInt64 *>(end - 8);
        res = intHash64(word ^ res);

        return res;
    }