From 0dd421414e0bf111269329a113753e0bf8591204 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 13 Apr 2024 13:11:32 +0300 Subject: feat(tvix/nix-compat/wire/bytes): add #[inline] for ensure_* funcs While the compiler might realize it's a good idea to inline these, especially considering this is in the same crate [1], it doesn't hurt to add that annotation too. Suggested in cl/11385. [1]: https://nnethercote.github.io/perf-book/inlining.html Change-Id: If679fce0e1aab9ec681ba60f689d386d6fd92d61 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11403 Tested-by: BuildkiteCI Reviewed-by: raitobezarius Autosubmit: flokli --- tvix/nix-compat/src/wire/bytes/reader.rs | 1 + tvix/nix-compat/src/wire/bytes/writer.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'tvix/nix-compat/src/wire') diff --git a/tvix/nix-compat/src/wire/bytes/reader.rs b/tvix/nix-compat/src/wire/bytes/reader.rs index 4c450b55db1a..c36729c6142b 100644 --- a/tvix/nix-compat/src/wire/bytes/reader.rs +++ b/tvix/nix-compat/src/wire/bytes/reader.rs @@ -60,6 +60,7 @@ where } } /// Returns an error if the passed usize is 0. +#[inline] fn ensure_nonzero_bytes_read(bytes_read: usize) -> Result { if bytes_read == 0 { Err(std::io::Error::new( diff --git a/tvix/nix-compat/src/wire/bytes/writer.rs b/tvix/nix-compat/src/wire/bytes/writer.rs index f278b8335f8f..347934b3dc8f 100644 --- a/tvix/nix-compat/src/wire/bytes/writer.rs +++ b/tvix/nix-compat/src/wire/bytes/writer.rs @@ -56,6 +56,7 @@ where } /// Returns an error if the passed usize is 0. +#[inline] fn ensure_nonzero_bytes_written(bytes_written: usize) -> Result { if bytes_written == 0 { Err(std::io::Error::new( -- cgit 1.4.1