egui/egui_demo_lib/benches
Emil Ernerfeldt b3e41e4e9c Use new type Estring to avoid cloning &'static str
`ui.label("static string")` is a very common use case,
and currently egui clones the string in these cases.

This PR introduces a new type:

``` rust
pub enum Estring {
    Static(&'static str),
    Owned(Arc<str>),
}
```

which is used everywhere text is needed, with
`impl Into<Estring>` in the API for e.g. `ui.label`.

This reduces the number of copies drastically and speeds up
the benchmark demo_with_tessellate__realistic by 17%.

This hurts the ergonomics of egui a bit, and this is a breaking change.

For instance, this used to work:

``` rust
fn my_label(ui: &mut egui::Ui, text: &str) {
    ui.label(text);
}
```

This must now either be changed to

``` rust
fn my_label(ui: &mut egui::Ui, text: &str) {
    ui.label(text.to_string());
}
```

(or the argument must be changed to either
`text: &'static str` or `text: String`)
2021-09-03 22:38:00 +02:00
..
benchmark.rs Use new type Estring to avoid cloning &'static str 2021-09-03 22:38:00 +02:00