Update World.hpp
Improve performance when zooming out all the way.
This commit is contained in:
@@ -12,16 +12,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
/// Implements a naiive-AF hashing algorithm for Vector2 class
|
||||
/// So we can use it as unique keys in std::unordered_map
|
||||
template<>
|
||||
struct std::hash<Vector2i>
|
||||
{
|
||||
std::size_t operator()(const Vector2i& k) const
|
||||
{
|
||||
return k.x; //Math::Pow(k.x, 3) + Math::Pow(k.y, 2);
|
||||
// Read 2x int32_t into one int64_t and return std::hash<int64_t> to prevent collisions.
|
||||
// This doesn't really gain any performance until you zoom out a lot.
|
||||
return std::hash<int64_t>()(((int64_t) k.x << 32) | ((int64_t) k.y));
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user