aboutsummaryrefslogtreecommitdiff
path: root/src/crates
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-03-08 17:35:02 +0000
committerAria Shrimpton <me@aria.rip>2024-03-08 17:35:02 +0000
commit6db389a0a7800c1a193dd2b983280a15c8319fcf (patch)
treeb1b12fe7300346b5ac358be736e8691538bb732d /src/crates
parentbe38ec4a6a85d9526ecedac36566f78522134edc (diff)
use binary search in sorteduniquevec::remove
Diffstat (limited to 'src/crates')
-rw-r--r--src/crates/library/src/sorted_unique_vector.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/crates/library/src/sorted_unique_vector.rs b/src/crates/library/src/sorted_unique_vector.rs
index 5cb0099..ffba865 100644
--- a/src/crates/library/src/sorted_unique_vector.rs
+++ b/src/crates/library/src/sorted_unique_vector.rs
@@ -147,8 +147,7 @@ impl<T: Ord + PartialEq> Container<T> for SortedUniqueVec<T> {
(define (post-remove xs r) (equal? r (op-remove xs)))
*ENDLIBSPEC*/
fn remove(&mut self, elt: T) -> Option<T> {
- let idx = self.iter().position(|x| *x == elt)?;
- Some(self.v.remove(idx))
+ self.v.remove(self.binary_search(elt).ok()?)
}
fn iter<'a>(&'a self) -> impl Iterator<Item = &'a T>