Minor improvements to bounded_vec and defensive. (#10873)

* Fix a few things in bounded_vec

* add test for try_extend

* Update frame/support/src/storage/bounded_vec.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* some review comments

* use swap

* remove clone

* use pop instead of truncate

* remove warn

* review comments

* Update frame/support/src/storage/bounded_vec.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* fix rustdoc

* fix links

* undo link

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Kian Paimani
2022-02-26 08:39:56 +00:00
committed by GitHub
parent 4c984500a7
commit b77d3f917d
5 changed files with 189 additions and 171 deletions
+1 -1
View File
@@ -866,7 +866,7 @@ impl<T: Config> Pallet<T> {
let new_pos = queue.binary_search_by_key(&ayes, |x| x.1).unwrap_or_else(|x| x);
branch = if maybe_old_pos.is_none() && new_pos > 0 {
// Just insert.
queue.force_insert_keep_right(new_pos, (index, ayes));
let _ = queue.force_insert_keep_right(new_pos, (index, ayes));
ServiceBranch::RequeuedInsertion
} else if let Some(old_pos) = maybe_old_pos {
// We were in the queue - slide into the correct position.
+1 -1
View File
@@ -86,7 +86,7 @@ impl<T: Ord, S: Get<u32>> InsertSorted<T> for BoundedVec<T, S> {
mut f: F,
) -> bool {
let index = self.binary_search_by_key::<K, F>(&f(&t), f).unwrap_or_else(|x| x);
self.force_insert_keep_right(index, t)
self.force_insert_keep_right(index, t).is_ok()
}
}