File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
starlark/src/values/types/set Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 19
19
20
20
use std:: mem;
21
21
22
+ use either:: Either ;
22
23
use starlark_derive:: starlark_module;
23
24
use starlark_map:: small_set:: SmallSet ;
24
25
use starlark_map:: Hashed ;
@@ -348,11 +349,19 @@ pub(crate) fn set_methods(builder: &mut MethodsBuilder) {
348
349
#[ starlark( require=pos) ] other : ValueOfUnchecked < ' v , StarlarkIter < Value < ' v > > > ,
349
350
heap : & ' v Heap ,
350
351
) -> starlark:: Result < bool > {
351
- let other = other. get ( ) . iterate ( heap) ?;
352
- //TODO (romanp) skip if other is larger
352
+ let other_var;
353
+ let other = if let Some ( other) = SetRef :: unpack_value_opt ( other. get ( ) ) {
354
+ if this. aref . content . len ( ) < other. aref . content . len ( ) {
355
+ return Ok ( false ) ;
356
+ }
357
+ other_var = other;
358
+ Either :: Left ( other_var. aref . content . iter_hashed ( ) . map ( |v| Ok ( v. copied ( ) ) ) )
359
+ } else {
360
+ Either :: Right ( other. get ( ) . iterate ( heap) ?. map ( |v| v. get_hashed ( ) ) )
361
+ } ;
362
+
353
363
for elem in other {
354
- let hashed = elem. get_hashed ( ) ?;
355
- if !this. aref . contains_hashed ( hashed) {
364
+ if !this. aref . contains_hashed ( elem?) {
356
365
return Ok ( false ) ;
357
366
}
358
367
}
You can’t perform that action at this time.
0 commit comments