From f10ef4947aeb2aca276a52bbb7f8fcefd045527a Mon Sep 17 00:00:00 2001 From: Stiopa Koltsov Date: Wed, 2 Oct 2024 10:56:07 -0700 Subject: [PATCH] set.pop without hashing Reviewed By: perehonchuk Differential Revision: D63740501 fbshipit-source-id: 541404b87342f6452c025c27f5f164dc0da9dcc1 --- starlark/src/values/types/set/methods.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/starlark/src/values/types/set/methods.rs b/starlark/src/values/types/set/methods.rs index 6b4a9457d..931e809b0 100644 --- a/starlark/src/values/types/set/methods.rs +++ b/starlark/src/values/types/set/methods.rs @@ -291,12 +291,8 @@ pub(crate) fn set_methods(builder: &mut MethodsBuilder) { /// ``` fn pop<'v>(this: Value<'v>) -> starlark::Result> { 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")), } }