@@ -6230,34 +6230,7 @@ function __evolved_builder_mt:has_all(...)
62306230 return true
62316231 end
62326232
6233- local has = self .has
6234- local has_all = self .has_all
6235-
6236- if fragment_count == 1 then
6237- local f1 = ...
6238- return has (self , f1 )
6239- end
6240-
6241- if fragment_count == 2 then
6242- local f1 , f2 = ...
6243- return has (self , f1 ) and has (self , f2 )
6244- end
6245-
6246- if fragment_count == 3 then
6247- local f1 , f2 , f3 = ...
6248- return has (self , f1 ) and has (self , f2 ) and has (self , f3 )
6249- end
6250-
6251- if fragment_count == 4 then
6252- local f1 , f2 , f3 , f4 = ...
6253- return has (self , f1 ) and has (self , f2 ) and has (self , f3 ) and has (self , f4 )
6254- end
6255-
6256- do
6257- local f1 , f2 , f3 , f4 = ...
6258- return has (self , f1 ) and has (self , f2 ) and has (self , f3 ) and has (self , f4 ) and
6259- has_all (self , __lua_select (5 , ... ))
6260- end
6233+ return self :has (... ) and self :has_all (__lua_select (2 , ... ))
62616234end
62626235
62636236--- @param ... evolved .fragment fragments
@@ -6270,34 +6243,7 @@ function __evolved_builder_mt:has_any(...)
62706243 return false
62716244 end
62726245
6273- local has = self .has
6274- local has_any = self .has_any
6275-
6276- if fragment_count == 1 then
6277- local f1 = ...
6278- return has (self , f1 )
6279- end
6280-
6281- if fragment_count == 2 then
6282- local f1 , f2 = ...
6283- return has (self , f1 ) or has (self , f2 )
6284- end
6285-
6286- if fragment_count == 3 then
6287- local f1 , f2 , f3 = ...
6288- return has (self , f1 ) or has (self , f2 ) or has (self , f3 )
6289- end
6290-
6291- if fragment_count == 4 then
6292- local f1 , f2 , f3 , f4 = ...
6293- return has (self , f1 ) or has (self , f2 ) or has (self , f3 ) or has (self , f4 )
6294- end
6295-
6296- do
6297- local f1 , f2 , f3 , f4 = ...
6298- return has (self , f1 ) or has (self , f2 ) or has (self , f3 ) or has (self , f4 ) or
6299- has_any (self , __lua_select (5 , ... ))
6300- end
6246+ return self :has (... ) or self :has_any (__lua_select (2 , ... ))
63016247end
63026248
63036249--- @param ... evolved .fragment fragments
@@ -6310,25 +6256,23 @@ function __evolved_builder_mt:get(...)
63106256 return
63116257 end
63126258
6313- local get = self .get
6314-
63156259 local fragment = ...
63166260
63176261 local component_index = self .__fragment_set [fragment ]
63186262
63196263 if not component_index then
6320- return nil , get (self , __lua_select (2 , ... ))
6264+ return nil , self : get (__lua_select (2 , ... ))
63216265 end
63226266
63236267 if component_index > self .__component_count then
6324- return nil , get (self , __lua_select (2 , ... ))
6268+ return nil , self : get (__lua_select (2 , ... ))
63256269 end
63266270
63276271 if fragment ~= self .__fragment_list [component_index ] then
6328- return nil , get (self , __lua_select (2 , ... ))
6272+ return nil , self : get (__lua_select (2 , ... ))
63296273 end
63306274
6331- return self .__component_list [component_index ], get (self , __lua_select (2 , ... ))
6275+ return self .__component_list [component_index ], self : get (__lua_select (2 , ... ))
63326276end
63336277
63346278--- @param fragment evolved.fragment
@@ -6381,45 +6325,46 @@ function __evolved_builder_mt:set(fragment, component)
63816325 return self
63826326end
63836327
6384- --- @param fragment evolved.fragment
6328+ --- @param ... evolved .fragment fragments
63856329--- @return evolved.builder builder
6386- function __evolved_builder_mt :remove (fragment )
6330+ function __evolved_builder_mt :remove (...)
6331+ local fragment_count = select (" #" , ... )
6332+
6333+ if fragment_count == 0 then
6334+ return self
6335+ end
6336+
6337+ local fragment = ...
6338+
63876339 local fragment_set = self .__fragment_set
63886340 local fragment_list = self .__fragment_list
63896341 local component_list = self .__component_list
63906342 local component_count = self .__component_count
63916343
63926344 local component_index = fragment_set [fragment ]
63936345
6394- if not component_index then
6395- return self
6396- end
6397-
6398- if component_index > component_count then
6399- return self
6400- end
6346+ if component_index
6347+ and component_index <= component_count
6348+ and fragment == fragment_list [ component_index ]
6349+ then
6350+ if component_index ~= component_count then
6351+ local last_fragment = fragment_list [ component_count ]
6352+ local last_component = component_list [ component_count ]
64016353
6402- if fragment ~= fragment_list [component_index ] then
6403- return self
6404- end
6354+ fragment_set [last_fragment ] = component_index
6355+ fragment_list [component_index ] = last_fragment
6356+ component_list [component_index ] = last_component
6357+ end
64056358
6406- if component_index ~= component_count then
6407- local last_fragment = fragment_list [component_count ]
6408- local last_component = component_list [component_count ]
6359+ fragment_set [ fragment ] = nil
6360+ fragment_list [component_count ] = nil
6361+ component_list [component_count ] = nil
64096362
6410- fragment_set [last_fragment ] = component_index
6411- fragment_list [component_index ] = last_fragment
6412- component_list [component_index ] = last_component
6363+ component_count = component_count - 1
6364+ self .__component_count = component_count
64136365 end
64146366
6415- fragment_set [fragment ] = nil
6416- fragment_list [component_count ] = nil
6417- component_list [component_count ] = nil
6418-
6419- component_count = component_count - 1
6420- self .__component_count = component_count
6421-
6422- return self
6367+ return self :remove (__lua_select (2 , ... ))
64236368end
64246369
64256370--- @return evolved.builder builder
0 commit comments