commit | 199741f76fdea652c7fe6323385705eb28c6f3eb | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Fri Oct 09 03:42:36 2020 +0000 |
committer | Automerger Merge Worker <[email protected]> | Fri Oct 09 03:42:36 2020 +0000 |
tree | 016def8e169faec1a21e319a82de77ec852c2ccd | |
parent | c35cd24066593df6b72b3f1d3006f0ddb0bd0978 [diff] | |
parent | e452407c06e538ab74d8472db10ed34ca99a66a1 [diff] |
[automerger skipped] Skip ab/6749736 in stage. am: 00867e8870 -s ours am: e452407c06 -s ours am skip reason: Change-Id I6f40c13954fc23f9e9d3b81198f0cdbd19dddfc4 with SHA-1 9e821675c0 is in history Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/12797252 Change-Id: Ic57e8ae9c268ad194b1767ffac6c477bc8a21a47
“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();