Commit d682405
Shrink code produced by
Currently `smallvec![]` expands to this:
```
{
let count = 0usize;
#[allow(unused_mut)]
let mut vec = ::smallvec::SmallVec::new();
if count <= vec.capacity() {
vec
} else {
::smallvec::SmallVec::from_vec(::alloc::vec::Vec::new())
}
};
```
This commit adds a rule to the `smallvec!` macro for the zero-length
case so it instead expands to this:
```
::smallvec::SmallVec::new()
```
The `std::vec!` macro already has a similar special case.
This commit also improves the non-zero case.
- It removes the `#[allow(unused_mut)]`, which was only needed for the
zero-length case.
- It changes the `*` repetitions to `+`. (Again, like `std::vec`.)smallvec![].1 parent 7c4d350 commit d682405
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 193 | + | |
| 194 | + | |
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
0 commit comments