Skip to content

Conversation

@borngraced
Copy link

Why?

All set_bytes callers follow the same pattern: save writer.len() as offset, write placeholder bytes (via write_*/skip), then call set_bytes to back-fill. Since bounds are already guaranteed by this usage pattern, the runtime checks are redundant I guess. This allows us to optimize them away while keeping a debug_assert! for safety...

What does this PR do?

Replace bounds-checked get_mut().unwrap().copy_from_slice() with direct ptr::copy_nonoverlapping.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

No benchmarks yet, but the improvement should be noticeable: https://godbolt.org/z/75bhPWxfW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant