commit | 00867e8870e57c3fc8f93a16a1119f36f62ad297 | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Thu Oct 08 17:21:37 2020 -0700 |
committer | Xin Li <[email protected]> | Thu Oct 08 17:21:37 2020 -0700 |
tree | 016def8e169faec1a21e319a82de77ec852c2ccd | |
parent | 2b62ce0785c8f9cdf33031fd008de363c1bff203 [diff] | |
parent | 9e821675c0de47ac521719b21946d8fc58918758 [diff] |
Skip ab/6749736 in stage. Merged-In: I6f40c13954fc23f9e9d3b81198f0cdbd19dddfc4 Change-Id: I760baba5ce1068cfe8091170a5b46101f334ee68
“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();