* [Horus] Fixes #3775 Quick fix ... comments welcome :) * Better hash function for strings * One comment, one! * One comment, one!
This commit is contained in:
+13
-1
@@ -99,7 +99,6 @@ int8_t calcRESXto100(int16_t x)
|
||||
return (x*25) >> 8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HELI) || defined(FRSKY_HUB) || defined(CPUARM)
|
||||
uint16_t isqrt32(uint32_t n)
|
||||
{
|
||||
@@ -172,3 +171,16 @@ void getGpsDistance()
|
||||
telemetryData.hub.maxGpsDistance = telemetryData.hub.gpsDistance;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
// djb2 hash algorithm
|
||||
uint32_t hash(const void * ptr, uint32_t size)
|
||||
{
|
||||
const uint8_t * data = (const uint8_t *)ptr;
|
||||
uint32_t hash = 5381;
|
||||
for (uint32_t i=0; i<size; i++) {
|
||||
hash = ((hash << 5) + hash) + data[i]; /* hash * 33 + c */
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user