Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lua/entities/gmod_wire_expression2/core/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ e2function number totalCpuUsage()
local owner = self.player
if not IsValid(owner) then return self.timebench end

return E2Lib.PlayerChips[owner]:getTotalTime()
-- To avoid creating new table
local chips = rawget(E2Lib.PlayerChips, owner)
if not chips then return self.timebench end

return chips:getTotalTime()
end

[nodiscard]
Expand Down
4 changes: 2 additions & 2 deletions lua/entities/gmod_wire_expression2/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ function ENT:OnRemove()
end

local owner = self.player
local chips = rawget(E2Lib.PlayerChips, owner)

if IsValid(owner) then
local chips = E2Lib.PlayerChips[owner]
if chips then
chips:remove(self)

if #chips == 0 then
Expand Down
Loading