Commit ebcac6a
committed
perf(codec): force inline of vlq_decode for hot loop
Marking the public vlq_decode entry point as #[inline(always)] instead of
just #[inline] lets rustc fully inline the VLQ inner loop into codec::decode
across crate boundaries. The previous `#[inline]` hint was insufficient for
the cross-crate hot path; the function-call overhead and tuple destructuring
of `(value, consumed)` dominated the per-segment work.
Real-world benchmark impact (codec::decode on isolated mappings strings):
- preact (17 KB): 68.6 us -> 17.2 us (-75%)
- chartjs (490 KB): 3.15 ms -> 1.22 ms (-61%)
- pdfjs (2297 KB): 11.49 ms -> 6.15 ms (-46%)
This closes most of the gap with the sourcemap crate's specialized
decode_mappings (which has always inlined its own vlq_fast helper because
it is private to the crate). The codec path remains slightly slower on
larger maps because it still allocates Vec<Vec<Segment>> per line, but
the inner-loop overhead is gone.1 parent ff7c35a commit ebcac6a
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
0 commit comments