Skip to content

Commit

Permalink
set union optimization
Browse files Browse the repository at this point in the history
Summary: as per title

Reviewed By: JakobDegen

Differential Revision: D65268912

fbshipit-source-id: 027db79121bc81132e98cc510e3dc62517f2b375
  • Loading branch information
perehonchuk authored and facebook-github-bot committed Nov 7, 2024
1 parent 54d7cfd commit be2cd13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions starlark/src/values/types/set/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ pub(crate) fn set_methods(builder: &mut MethodsBuilder) {
#[starlark(require=pos)] other: ValueOfUnchecked<'v, StarlarkIter<Value<'v>>>,
heap: &'v Heap,
) -> starlark::Result<SetData<'v>> {
let it = other.get().iterate(heap)?;
// TODO(romanp) omptimize if this is empty
if this.aref.content.is_empty() {
let other_set = SetFromValue::from_value(other, heap)?;
return Ok(SetData {
content: other_set.into_set(),
});
}
let mut data = this.aref.content.clone();
for elem in it {
for elem in other.get().iterate(heap)? {
let hashed = elem.get_hashed()?;
data.insert_hashed(hashed);
}
Expand Down

0 comments on commit be2cd13

Please sign in to comment.