rust-lang/rust — pull request #16698 by bluss (2014-08-23 10:36:40+00:00)
Title: Address &str.slice is bloated

These are somewhat stop-gap solutions to address #16625

1. Remove entirely unnecessary formatting for the simple assert cases. That is `assert!(expr)` only needs `concat! + stringify!`

2. Simplify error reporting in `.slice()`, simply don't have friendly error messages anymore, no string formatting in `fail!` or `assert!`.

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 6.0 kB llvm IR, and the number of `unreachable` calls drops from 5 to 1.