Commit 71c8abb
authored
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![]. (#385)1 parent 4fe4068 commit 71c8abb
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2140 | 2140 | | |
2141 | 2141 | | |
2142 | 2142 | | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
2143 | 2146 | | |
2144 | 2147 | | |
2145 | 2148 | | |
2146 | | - | |
2147 | | - | |
2148 | | - | |
| 2149 | + | |
| 2150 | + | |
2149 | 2151 | | |
2150 | 2152 | | |
2151 | 2153 | | |
2152 | 2154 | | |
2153 | 2155 | | |
2154 | | - | |
| 2156 | + | |
2155 | 2157 | | |
2156 | 2158 | | |
2157 | 2159 | | |
| |||
0 commit comments