commit | 2188055b689f093e1e3a439a935cda2f2f44ab42 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Sat Feb 20 00:24:23 2021 -0800 |
committer | Xin Li <delphij@google.com> | Sat Feb 20 00:24:23 2021 -0800 |
tree | 301fc457c178d7a6e8031eb136d7bf951a404406 | |
parent | c37fb7ee60f4a80b8509b7938a9172fed073006a [diff] | |
parent | c62d25ec3e666d7b3d0489593fe3e6025886f00c [diff] |
Mark ab/7061308 as merged in stage. Bug: 180401296 Merged-In: Ib1995bab25327524c008ae00be310a764aa19f18 Change-Id: I7f0dd62c09e016d2a66865c1a05f2c8b8aed2d3b
"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();