≈ the.bay.news

Pass small structs by value or reference?

The Rust Programming Language Forum
Pass small structs by value or reference?
I have a struct: struct DocPos { block: Uuid, offset: usize, flags: u32 } And lots of functions around it, for example: fn doc_pos_to_utf16_index(pos: DocPos) -> Utf16Index fn compare_positions(&self, a: &DocPos, b: &DocPos) -> Ordering But they take a confused mix of DocPos and &DocPos. Where is the cutoff size when it becomes more efficient to pass by & rather than copy? Does it depend on the type of function or the other arguments? That struct is 32 bytes. Though I may remov...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.