Micro-optimization for E2Lib.IsOwner (#3162)

Remove the singleplayer check and just define the function right away
This commit is contained in:
Astralcircle 2024-10-29 02:55:39 +03:00 committed by GitHub
parent 185717464f
commit 6f7f2c8e53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -466,12 +466,17 @@ function E2Lib.isFriend(owner, player)
return owner == player
end
function E2Lib.isOwner(self, entity)
if game.SinglePlayer() then return true end
local owner = E2Lib.getOwner(self, entity)
if not IsValid(owner) then return false end
return E2Lib.isFriend(owner, self.player)
if game.SinglePlayer() then
function E2Lib.isOwner(self, entity)
return true
end
else
function E2Lib.isOwner(self, entity)
local owner = E2Lib.getOwner(self, entity)
if not IsValid(owner) then return false end
return E2Lib.isFriend(owner, self.player)
end
end
local isOwner = E2Lib.isOwner