nak: Reserve capacity in LiveSet::from_iter,extend
Reviewed-by: Mary Guillemard <mary@mary.zone> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33306>
This commit is contained in:
@@ -108,6 +108,8 @@ impl LiveSet {
|
||||
impl FromIterator<SSAValue> for LiveSet {
|
||||
fn from_iter<T: IntoIterator<Item = SSAValue>>(iter: T) -> Self {
|
||||
let mut set = LiveSet::new();
|
||||
let iter = iter.into_iter();
|
||||
set.set.reserve(iter.size_hint().0);
|
||||
for ssa in iter {
|
||||
set.insert(ssa);
|
||||
}
|
||||
@@ -117,6 +119,8 @@ impl FromIterator<SSAValue> for LiveSet {
|
||||
|
||||
impl Extend<SSAValue> for LiveSet {
|
||||
fn extend<T: IntoIterator<Item = SSAValue>>(&mut self, iter: T) {
|
||||
let iter = iter.into_iter();
|
||||
self.set.reserve(iter.size_hint().0);
|
||||
for ssa in iter {
|
||||
self.insert(ssa);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user