rust/src/libserialize
Dylan DPC a50a896755
Rollup merge of #69050 - nnethercote:micro-optimize-leb128, r=michaelwoerister
Micro-optimize the heck out of LEB128 reading and writing.

This commit makes the following writing improvements:
- Removes the unnecessary `write_to_vec` function.
- Reduces the number of conditions per loop from 2 to 1.
- Avoids a mask and a shift on the final byte.

And the following reading improvements:
- Removes an unnecessary type annotation.
- Fixes a dangerous unchecked slice access. Imagine a slice `[0x80]` --
  the current code will read past the end of the slice some number of
  bytes. The bounds check at the end will subsequently trigger, unless
  something bad (like a crash) happens first. The cost of doing bounds
  check in the loop body is negligible.
- Avoids a mask on the final byte.

And the following improvements for both reading and writing:
- Changes `for` to `loop` for the loops, avoiding an unnecessary
  condition on each iteration. This also removes the need for
  `leb128_size`.

All of these changes give significant perf wins, up to 5%.

r? @michaelwoerister
2020-02-13 02:52:54 +01:00
..
hex Format the world 2019-12-22 17:42:47 -05:00
json Format the world 2019-12-22 17:42:47 -05:00
tests Format the world 2019-12-22 17:42:47 -05:00
Cargo.toml bump smallvec to 1.0 2019-11-04 15:59:09 +01:00
collection_impls.rs Format the world 2019-12-22 17:42:47 -05:00
hex.rs Deprecate Error::description for real 2019-12-24 22:39:49 -08:00
json.rs Deprecate Error::description for real 2019-12-24 22:39:49 -08:00
leb128.rs Micro-optimize the heck out of LEB128 reading and writing. 2020-02-11 19:07:43 +11:00
lib.rs Remove unused feature gate from libserialize 2020-02-07 13:59:31 +01:00
opaque.rs Remove unused read_uleb128 parameter. 2020-01-30 15:22:53 +11:00
serialize.rs Format the world 2019-12-22 17:42:47 -05:00