-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
c: coreCore componentsCore componentsquestionNot a problem with the library, but a question regarding usage.Not a problem with the library, but a question regarding usage.
Description
If I've understood it correctly, constructing a StringName once and then doing .clone() of it is non-negligibly more efficient than constructing it of &str from scratch every time we need a StringName to pass to the Godot API. So, naturally, .clone() should be used quite often:
fn init(base: Base<Self::Base>) -> Self {
Self {
velocity: Vector2::ZERO,
input: Input::singleton(),
ui_left: "ui_left".into(),
ui_right: "ui_right".into(),
ui_up: "ui_up".into(),
ui_down: "ui_down".into(),
base,
}
}
fn process(&mut self, delta: f64) {
let o /*bject */ = self;
o.velocity =
o.input.get_vector(o.ui_left.clone(), o.ui_right.clone(), o.ui_up.clone(), o.ui_down.clone());
...
}So, why not do #[derive(Copy)] on StringName to make it less hairy?
Lamby777
Metadata
Metadata
Assignees
Labels
c: coreCore componentsCore componentsquestionNot a problem with the library, but a question regarding usage.Not a problem with the library, but a question regarding usage.