BTreeSet: remove duplicated code by reusing from_sorted_iter

The method `BTreeSet::from_sorted_iter` was introduced in 49ccb7519f,
but it was not consistently used throughout the codebase. As a result, some code redundantly reimplemented its logic.
This commit fixes the problem.
This commit is contained in:
Cheng Xu
2025-06-27 11:01:59 -07:00
parent 13c46fd0b0
commit cd1713ebba
+1 -3
View File
@@ -1517,9 +1517,7 @@ fn from_sorted_iter<I: Iterator<Item = T>>(iter: I, alloc: A) -> BTreeSet<T, A>
// use stable sort to preserve the insertion order.
arr.sort();
let iter = IntoIterator::into_iter(arr).map(|k| (k, SetValZST::default()));
let map = BTreeMap::bulk_build_from_sorted_iter(iter, Global);
BTreeSet { map }
BTreeSet::from_sorted_iter(IntoIterator::into_iter(arr), Global)
}
}