Code generation for str::contains


#1

Hi,

I usually poke at generate disassembly code now and then because I like to be aware of what kind of assembly the code I write generates (even if it may not be super performance critical I like to have a good idea about it)

When using something like this

let t0 = "foo";
let t1 = "bar";

if t0.contains(t1) {
   ...
}

Example over here https://play.rust-lang.org/?gist=f9a5f33f784b459ea62f&version=stable (make sure to switch to Release and hit “Asm” to see disassembly)

I the disassembly listing becomes quite big. I wonder if this is expected when calling the contain function on str?

Cheers.


#2

The Rust standard library uses the “inline” attribute in some places to inline small pieces of code from the standard library into user code, to improve performance. That said, it looks like someone got overly aggressive with “inline” markings; please file a bug (https://github.com/rust-lang/rust/issues).


#3

Yeah it seems that the inlining is quite aggressive here indeed. I will file a bug on this. Thanks!

(filled here https://github.com/rust-lang/rust/issues/30617)