mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 12:24:11 -04:00
Add optional optimization for worlds and systems
This commit is contained in:
parent
56b5244541
commit
6aeb91d984
4 changed files with 58 additions and 57 deletions
|
@ -2,10 +2,13 @@
|
|||
|
||||
local PATH = (...):gsub('%.[^%.]+$', '')
|
||||
|
||||
local Type = require(PATH..".type")
|
||||
local List = require(PATH..".list")
|
||||
local Type = require(PATH..".type")
|
||||
local List = require(PATH..".list")
|
||||
local Utils = require(PATH..".utils")
|
||||
|
||||
local World = {}
|
||||
local World = {
|
||||
ENABLE_OPTIMIZATION = true,
|
||||
}
|
||||
World.__index = World
|
||||
|
||||
--- Creates a new World.
|
||||
|
@ -26,6 +29,13 @@ function World.new()
|
|||
__isWorld = true,
|
||||
}, World)
|
||||
|
||||
-- Optimization: We deep copy the World class into our instance of a world.
|
||||
-- This grants slightly faster access times at the cost of memory.
|
||||
-- Since there (generally) won't be many instances of worlds this is a worthwhile tradeoff
|
||||
if (World.ENABLE_OPTIMIZATION) then
|
||||
Utils.shallowCopy(World, world)
|
||||
end
|
||||
|
||||
return world
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue