@@ -798,10 +798,11 @@ end
798798
799799--- @generic V
800800--- @param list V[]
801+ --- @param size ? integer
801802--- @return V[]
802803--- @nodiscard
803- function __list_dup (list )
804- local list_size = # list
804+ function __list_dup (list , size )
805+ local list_size = size or # list
805806
806807 if list_size == 0 then
807808 return {}
@@ -820,10 +821,11 @@ end
820821--- @param list V[]
821822--- @param item V
822823--- @param comp ? fun ( a : V , b : V ): boolean
824+ --- @param size ? integer
823825--- @return integer lower_bound_index
824826--- @nodiscard
825- function __list_lwr (list , item , comp )
826- local lower , upper = 1 , # list
827+ function __list_lwr (list , item , comp , size )
828+ local lower , upper = 1 , size or # list
827829
828830 if comp then
829831 while lower <= upper do
858860---
859861---
860862
863+ local __table_dup
864+
865+ --- @generic K , V
866+ --- @param table table<K , V>
867+ --- @return table<K , V>
868+ --- @nodiscard
869+ function __table_dup (table )
870+ local dup_table = {}
871+
872+ for k , v in __lua_next , table do
873+ dup_table [k ] = v
874+ end
875+
876+ return dup_table
877+ end
878+
879+ ---
880+ ---
881+ ---
882+ ---
883+ ---
884+
861885--- @class (exact ) evolved.assoc_list <K >: {
862886--- __item_set: { [K]: integer },
863887--- __item_list: K[],
@@ -1407,7 +1431,7 @@ end
14071431function __add_root_chunk (root )
14081432 local root_index = __list_lwr (__root_list , root , function (a , b )
14091433 return a .__fragment < b .__fragment
1410- end )
1434+ end , __root_count )
14111435
14121436 for sib_root_index = __root_count , root_index , - 1 do
14131437 local sib_root = __root_list [sib_root_index ]
@@ -1452,7 +1476,7 @@ end
14521476function __add_child_chunk (child , parent )
14531477 local child_index = __list_lwr (parent .__child_list , child , function (a , b )
14541478 return a .__fragment < b .__fragment
1455- end )
1479+ end , parent . __child_count )
14561480
14571481 for sib_child_index = parent .__child_count , child_index , - 1 do
14581482 local sib_child = parent .__child_list [sib_child_index ]
@@ -6226,47 +6250,13 @@ function __evolved_collect_garbage()
62266250 end
62276251
62286252 do
6229- --- @type table<integer , evolved.chunk>
6230- local new_entity_chunks = {}
6231-
6232- for entity_primary , entity_chunk in __lua_next , __entity_chunks do
6233- new_entity_chunks [entity_primary ] = entity_chunk
6234- end
6235-
6236- __entity_chunks = new_entity_chunks
6253+ __entity_chunks = __table_dup (__entity_chunks )
6254+ __entity_places = __table_dup (__entity_places )
62376255 end
62386256
62396257 do
6240- --- @type table<integer , integer>
6241- local new_entity_places = {}
6242-
6243- for entity_primary , entity_place in __lua_next , __entity_places do
6244- new_entity_places [entity_primary ] = entity_place
6245- end
6246-
6247- __entity_places = new_entity_places
6248- end
6249-
6250- do
6251- --- @type integer[]
6252- local new_defer_points = __lua_table_new (__defer_depth )
6253-
6254- __lua_table_move (
6255- __defer_points , 1 , __defer_depth ,
6256- 1 , new_defer_points )
6257-
6258- __defer_points = new_defer_points
6259- end
6260-
6261- do
6262- --- @type any[]
6263- local new_defer_bytecode = __lua_table_new (__defer_length )
6264-
6265- __lua_table_move (
6266- __defer_bytecode , 1 , __defer_length ,
6267- 1 , new_defer_bytecode )
6268-
6269- __defer_bytecode = new_defer_bytecode
6258+ __defer_points = __list_dup (__defer_points , __defer_depth )
6259+ __defer_bytecode = __list_dup (__defer_bytecode , __defer_length )
62706260 end
62716261
62726262 __evolved_commit ()
0 commit comments