mirror of
https://github.com/bevyengine/bevy
synced 2025-01-02 00:08:53 +00:00
Added a few more FunctionMap optimizations
Mainly usage of HashMap::insert_unique_unchecked
This commit is contained in:
parent
841d1bc717
commit
f4d8c2f16a
1 changed files with 13 additions and 5 deletions
|
@ -128,10 +128,14 @@ impl<F> FunctionMap<F> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut map = HashMap::new();
|
||||||
|
map.insert_unique_unchecked(self_sig, 0);
|
||||||
|
map.insert_unique_unchecked(other_sig, 1);
|
||||||
|
|
||||||
Ok(Self::Overloaded(
|
Ok(Self::Overloaded(
|
||||||
vec![self_func, other_func],
|
vec![self_func, other_func],
|
||||||
vec![self_info, other_info],
|
vec![self_info, other_info],
|
||||||
HashMap::from_iter([(self_sig, 0), (other_sig, 1)]),
|
map,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
|
@ -154,7 +158,7 @@ impl<F> FunctionMap<F> {
|
||||||
|
|
||||||
other_funcs.insert(0, self_func);
|
other_funcs.insert(0, self_func);
|
||||||
other_infos.insert(0, self_info);
|
other_infos.insert(0, self_info);
|
||||||
other_indices.insert(self_sig, 0);
|
other_indices.insert_unique_unchecked(self_sig, 0);
|
||||||
|
|
||||||
Ok(Self::Overloaded(other_funcs, other_infos, other_indices))
|
Ok(Self::Overloaded(other_funcs, other_infos, other_indices))
|
||||||
}
|
}
|
||||||
|
@ -175,7 +179,7 @@ impl<F> FunctionMap<F> {
|
||||||
let index = self_funcs.len();
|
let index = self_funcs.len();
|
||||||
self_funcs.push(other_func);
|
self_funcs.push(other_func);
|
||||||
self_infos.push(other_info);
|
self_infos.push(other_info);
|
||||||
self_indices.insert(other_sig, index);
|
self_indices.insert_unique_unchecked(other_sig, index);
|
||||||
|
|
||||||
Ok(Self::Overloaded(self_funcs, self_infos, self_indices))
|
Ok(Self::Overloaded(self_funcs, self_infos, self_indices))
|
||||||
}
|
}
|
||||||
|
@ -195,10 +199,14 @@ impl<F> FunctionMap<F> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
new_indices.insert(sig, self_funcs.len() + index);
|
new_indices.insert_unique_unchecked(sig, self_funcs.len() + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
self_indices.reserve(new_indices.len());
|
||||||
|
for (sig, index) in new_indices {
|
||||||
|
self_indices.insert_unique_unchecked(sig, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
self_indices.extend(new_indices);
|
|
||||||
self_funcs.append(&mut other_funcs);
|
self_funcs.append(&mut other_funcs);
|
||||||
// The index map and `FunctionInfo` list should always be in sync,
|
// The index map and `FunctionInfo` list should always be in sync,
|
||||||
// so we can simply append the new infos to the existing ones.
|
// so we can simply append the new infos to the existing ones.
|
||||||
|
|
Loading…
Reference in a new issue