Skip to content

Commit

Permalink
Precompute hashed type
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Sep 27, 2024
1 parent 73147f3 commit 6def84e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ local function archetype_append_to_records(
end
end

local function archetype_create(world: World, types: { i24 }, prev: i53?): Archetype
local ty = hash(types)

local function archetype_create(world: World, types: { i24 }, ty, prev: i53?): Archetype
local archetype_id = (world.nextArchetypeId :: number) + 1
world.nextArchetypeId = archetype_id

Expand Down Expand Up @@ -558,7 +556,7 @@ local function archetype_ensure(world: World, types): Archetype
return archetype
end

return archetype_create(world, types)
return archetype_create(world, types, ty)
end

local function find_insert(types: { i53 }, toAdd: i53): number
Expand Down Expand Up @@ -1743,7 +1741,7 @@ function World.new()
ROOT_ARCHETYPE = (nil :: any) :: Archetype,
}, World) :: any

self.ROOT_ARCHETYPE = archetype_create(self, {})
self.ROOT_ARCHETYPE = archetype_create(self, {}, "")

for i = HI_COMPONENT_ID + 1, EcsRest do
-- Initialize built-in components
Expand Down

0 comments on commit 6def84e

Please sign in to comment.