From 67a9df686ec1fc7a43f1b3e81dc4e3d81bfff008 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 24 Dec 2020 02:06:08 -0800 Subject: [PATCH] Add fast path for NavPoint equality. Hot method and the FFI costs for comparing the points are not cheap. --- game/navmesh.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game/navmesh.py b/game/navmesh.py index 2b0fdd81..c1ac6ab0 100644 --- a/game/navmesh.py +++ b/game/navmesh.py @@ -50,6 +50,9 @@ class NavPoint: return hash(self.poly.ident) def __eq__(self, other: object) -> bool: + if id(self) == id(other): + return True + if not isinstance(other, NavPoint): return False