commit | b0384d4d744ee78c70aecf0a3997b8e6866434a0 | [log] [tgz] |
---|---|---|
author | Daniel Norman <danielnorman@google.com> | Mon Nov 30 11:41:51 2020 -0800 |
committer | Daniel Norman <danielnorman@google.com> | Mon Nov 30 11:41:51 2020 -0800 |
tree | 5b081fe46bd8d5f84c1fcfcf68c07003059a4866 | |
parent | 998eb9a8270041f74067a37791366656db18ee7f [diff] | |
parent | 8df14539667290d3c3daab6797dbf0132fa84c3e [diff] |
Merge SP1A.201130.001 Change-Id: I7200fca4fdd08bcc2cf9787881a77ea5ba9b4133
"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();