egui/epaint/src
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
..
text Use new type Estring to avoid cloning &'static str 2021-09-03 22:38:00 +02:00
color.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
lib.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
mesh.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
mutex.rs Detect single-threaded mutex reentry in debug mode (#433) 2021-05-26 22:13:24 +02:00
shadow.rs Style tweaks (#450) 2021-06-12 15:53:56 +02:00
shape.rs Use new type Estring to avoid cloning &'static str 2021-09-03 22:38:00 +02:00
shape_transform.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
stats.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
stroke.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
tessellator.rs New text layout (#682) 2021-09-03 18:18:00 +02:00
texture_atlas.rs egui_web: make text thicker and less pixelated (#640) 2021-08-21 21:18:00 +02:00