Skip to content

Commit

Permalink
set.pop without hashing
Browse files Browse the repository at this point in the history
Reviewed By: perehonchuk

Differential Revision: D63740501

fbshipit-source-id: 541404b87342f6452c025c27f5f164dc0da9dcc1
  • Loading branch information
stepancheg authored and facebook-github-bot committed Oct 2, 2024
1 parent bfeebe5 commit f10ef49
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions starlark/src/values/types/set/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,8 @@ pub(crate) fn set_methods(builder: &mut MethodsBuilder) {
/// ```
fn pop<'v>(this: Value<'v>) -> starlark::Result<Value<'v>> {
let mut set = SetMut::from_value(this)?;
let first = set.aref.iter_hashed().next();
match first {
Some(x) => {
set.aref.remove_hashed(x.as_ref());
Ok(x.into_key())
}
match set.aref.content.shift_remove_index(0) {
Some(x) => Ok(x),
None => Err(value_error!("pop from an empty set")),
}
}
Expand Down

0 comments on commit f10ef49

Please sign in to comment.