Closed maxpiepenbrink closed 2 weeks ago
Feel free to shoot this down :) Just ran into this while playing around with a text heavy prototype in MacroQuad where a single draw might be building 30+ of these every frame. The cost is negligible but a & prefix didn't feel much worse than .clone() or TextParams { blah, ..defaults::Default() }
or TextParams::default()
everywhere.
Example case using this change:
impl Displayable for Header {
fn draw(&self, context: &MenuContext) {
let measure = measure_text(
&self.text,
context.text_params.font,
context.text_params.font_size,
context.text_params.font_scale,
);
draw_text_ex(
&self.text,
context.screen_center_x - (measure.width / 2.0),
20.0,
&context.text_params, // <-- currently have to .clone() this instead
);
}
}
I completely overlooked that many of the other _ex
functions are also not passing by reference, I have to assume this is just intentional then! 👍 carry on
I agree, an extra &
is not a big deal. But, yes, changing all those functions would be too much of a breaking change :(
If you're re-using
TextParams
for various things, it can be a little clumsy to need to.clone()
it everywhere.