Commit 27bddcb
committed
Speed up
Currently it just calls `truncate(0)`. `truncate()` is (a) not marked as
`#[inline]`, and (b) more general than needed for `clear()`.
This commit changes `clear()` to do the work itself. This modest change
was first proposed in #74172, where the reviewer rejected it because
there was insufficient evidence that `Vec::clear()`'s performance
mattered enough to justify the change. Recent changes within rustc have
made `Vec::clear()` hot within `macro_parser.rs`, so the change is now
clearly worthwhile.
Note that this will also benefit `String::clear()`, because it just
calls `Vec::clear()`.Vec::clear().1 parent 6a9080b commit 27bddcb
1 file changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1881 | 1881 | | |
1882 | 1882 | | |
1883 | 1883 | | |
1884 | | - | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
1885 | 1896 | | |
1886 | 1897 | | |
1887 | 1898 | | |
| |||
0 commit comments