… | |
… | |
237 | #if 0 |
237 | #if 0 |
238 | // and has a max. error of 6 in the range -100..+100. |
238 | // and has a max. error of 6 in the range -100..+100. |
239 | #else |
239 | #else |
240 | // and has a max. error of 9 in the range -100..+100. |
240 | // and has a max. error of 9 in the range -100..+100. |
241 | #endif |
241 | #endif |
242 | inline int |
242 | inline int |
243 | idistance (int dx, int dy) |
243 | idistance (int dx, int dy) |
244 | { |
244 | { |
245 | unsigned int dx_ = abs (dx); |
245 | unsigned int dx_ = abs (dx); |
246 | unsigned int dy_ = abs (dy); |
246 | unsigned int dy_ = abs (dy); |
247 | |
247 | |
248 | #if 0 |
248 | #if 0 |
249 | return dx_ > dy_ |
249 | return dx_ > dy_ |
… | |
… | |
407 | typedef const Tp *const_pointer; |
407 | typedef const Tp *const_pointer; |
408 | typedef Tp &reference; |
408 | typedef Tp &reference; |
409 | typedef const Tp &const_reference; |
409 | typedef const Tp &const_reference; |
410 | typedef Tp value_type; |
410 | typedef Tp value_type; |
411 | |
411 | |
412 | template <class U> |
412 | template <class U> |
413 | struct rebind |
413 | struct rebind |
414 | { |
414 | { |
415 | typedef slice_allocator<U> other; |
415 | typedef slice_allocator<U> other; |
416 | }; |
416 | }; |
417 | |
417 | |
… | |
… | |
597 | // with good distribution. |
597 | // with good distribution. |
598 | // FNV-1a is faster on many cpus because the multiplication |
598 | // FNV-1a is faster on many cpus because the multiplication |
599 | // runs concurrently with the looping logic. |
599 | // runs concurrently with the looping logic. |
600 | // we modify the hash a bit to improve its distribution |
600 | // we modify the hash a bit to improve its distribution |
601 | uint32_t hash = STRHSH_NULL; |
601 | uint32_t hash = STRHSH_NULL; |
602 | |
602 | |
603 | while (*s) |
603 | while (*s) |
604 | hash = (hash ^ *s++) * 16777619U; |
604 | hash = (hash ^ *s++) * 16777619U; |
605 | |
605 | |
606 | return hash ^ (hash >> 16); |
606 | return hash ^ (hash >> 16); |
607 | } |
607 | } |
608 | |
608 | |
609 | static inline uint32_t |
609 | static inline uint32_t |
610 | memhsh (const char *s, size_t len) |
610 | memhsh (const char *s, size_t len) |
611 | { |
611 | { |
612 | uint32_t hash = STRHSH_NULL; |
612 | uint32_t hash = STRHSH_NULL; |
613 | |
613 | |
614 | while (len--) |
614 | while (len--) |
615 | hash = (hash ^ *s++) * 16777619U; |
615 | hash = (hash ^ *s++) * 16777619U; |
616 | |
616 | |
617 | return hash; |
617 | return hash; |
618 | } |
618 | } |