]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #16698 : bluss/rust/slice-bloat, r=huonw
authorbors <bors@rust-lang.org>
Sun, 24 Aug 2014 03:10:59 +0000 (03:10 +0000)
committerbors <bors@rust-lang.org>
Sun, 24 Aug 2014 03:10:59 +0000 (03:10 +0000)
These are somewhat stop-gap solutions to address #16625

core: Separate failure formatting in str methods slice, slice_to, slice_from

Use a separate inline-never function to format failure message for
str::slice() errors.

Using strcat's idea, this makes sure no formatting code from failure is
inlined when str::slice() is inlined. The number of `unreachable` being
inlined when usingi `.slice()` drops from 5 to just 1.

The testcase:

```
#![crate_type = "lib"]
pub fn slice(x: &str, a: uint, b: uint) -> &str {
    x.slice(a, b)
}
```

shrinks from 16.9 kB to 3.3 kB llvm IR, and the number of `unreachable` drops from 5 to 1.

1  2 
src/libcore/str.rs

Simple merge