Optimizations: Removed unnecessary lookups when comparing objects with the = operator (used a lot in moving and messaging)
This commit is contained in:
parent
563361a676
commit
724027d134
1 changed files with 8 additions and 2 deletions
|
|
@ -19,6 +19,10 @@ from src.typeclasses.typeclass import TypeClass
|
||||||
from src.commands import cmdset, command
|
from src.commands import cmdset, command
|
||||||
__all__ = ("Object", "Character", "Room", "Exit")
|
__all__ = ("Object", "Character", "Room", "Exit")
|
||||||
|
|
||||||
|
_GA = object.__getattribute__
|
||||||
|
_SA = object.__setattr__
|
||||||
|
_DA = object.__delattr__
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base class to inherit from.
|
# Base class to inherit from.
|
||||||
#
|
#
|
||||||
|
|
@ -358,11 +362,13 @@ class Object(TypeClass):
|
||||||
parent doesn't work.
|
parent doesn't work.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.dbref == other or self.dbref == other.dbref
|
return _GA(self, "dbid") == other \
|
||||||
|
or _GA(self, "dbid") == _GA(other, "dbid")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# compare players instead
|
# compare players instead
|
||||||
try:
|
try:
|
||||||
return self.player.uid == other or self.player.uid == other.player.uid
|
return _GA(_GA(self, "player"),"uid") == other \
|
||||||
|
or _GA(_GA(self, "player"),"uid") == _GA(_GA(other, "player"),"uid")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue