7
submitted 4 days ago by cm0002@lemdro.id to c/rust@programming.dev

Thing I stumbled upon:

I added boolean argument & if statement inside sort_unstable_by closure:

//from
|&a, &b| compare(a, b) 

//to
|&a, &b| if is_reverse { compare(b, a) } else { compare(a, b) }

I expected binary to grow slightly, but actually got 1KB smaller.

I dug into & found that the reason is: quicksort fn became 980 bytes smaller.

Why? Not sure. Inlining looks same, quicksort just has fewer instructions.

target: arm-unknown-linux-gnueabihf

commit: https://github.com/tracyspacy/fli/commit/a87a98be77cc1972a53e6399716a227d1135e76b

details: https://pastebin.com/qJdTw49n

OC by @tracyspcy@lemmy.ml

top 1 comments
sorted by: hot top controversial new old
[-] anton 3 points 4 days ago

Weird. I threw it in compiler explorer and the assembly got longer (as expected).

this post was submitted on 02 Jul 2026
7 points (100.0% liked)

Rust

8120 readers
1 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS