commit | 2f652d2ca57fd625094cac475b03cb7fe1fb4b17 | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Wed Nov 25 05:40:08 2020 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed Nov 25 05:40:08 2020 +0000 |
tree | 5b081fe46bd8d5f84c1fcfcf68c07003059a4866 | |
parent | 12905cced09a9dbd70f6dcf932cc8a29c16ee940 [diff] | |
parent | c62d25ec3e666d7b3d0489593fe3e6025886f00c [diff] |
Mark ab/6881855 as merged am: c9b20fca29 am: c62d25ec3e Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/13112903 Change-Id: I56043b1711081dc385709ab03216e56ad9dd54a9
“Small vector” optimization for Rust: store up to a small number of items on the stack
use smallvec::{SmallVec, smallvec}; // This SmallVec can hold up to 4 items on the stack: let mut v: SmallVec<[i32; 4]> = smallvec![1, 2, 3, 4]; // It will automatically move its contents to the heap if // contains more than four items: v.push(5); // SmallVec points to a slice, so you can use normal slice // indexing and other methods to access its contents: v[0] = v[1] + v[2]; v.sort();