MCPcopy Create free account
hub / github.com/creatale/node-dv / getHash

Function getHash

deps/lodepng/lodepng.cpp:1429–1448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1427
1428
1429static unsigned getHash(const unsigned char* data, size_t size, size_t pos)
1430{
1431 unsigned result = 0;
1432 if(pos + 2 < size)
1433 {
1434 /*A simple shift and xor hash is used. Since the data of PNGs is dominated
1435 by zeroes due to the filters, a better hash does not have a significant
1436 effect on speed in traversing the chain, and causes more time spend on
1437 calculating the hash.*/
1438 result ^= (unsigned)(data[pos + 0] << 0u);
1439 result ^= (unsigned)(data[pos + 1] << 4u);
1440 result ^= (unsigned)(data[pos + 2] << 8u);
1441 } else {
1442 size_t amount, i;
1443 if(pos >= size) return 0;
1444 amount = size - pos;
1445 for(i = 0; i != amount; ++i) result ^= (unsigned)(data[pos + i] << (i * 8u));
1446 }
1447 return result & HASH_BIT_MASK;
1448}
1449
1450static unsigned countZeros(const unsigned char* data, size_t size, size_t pos)
1451{

Callers 1

encodeLZ77Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected