Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache function pointers in global tables #387

Merged
merged 9 commits into from
Sep 5, 2023
15 changes: 7 additions & 8 deletions godot-bindings/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ impl StopWatch {
}
}

pub fn record(&mut self, what: &'static str) {
pub fn record(&mut self, what: impl Into<String>) {
let now = Instant::now();
let duration = now - self.last_instant;
let name = what.into();

self.last_instant = now;
self.lwidth = usize::max(self.lwidth, what.len());
self.metrics.push(Metric {
name: what,
duration,
});
self.lwidth = usize::max(self.lwidth, name.len());
self.metrics.push(Metric { name, duration });
}

pub fn write_stats_to(self, to_file: &Path) {
Expand All @@ -48,7 +47,7 @@ impl StopWatch {
}
let rwidth = log10(total.as_millis());
let total_metric = Metric {
name: "total",
name: "total".to_string(),
duration: total,
};

Expand Down Expand Up @@ -79,6 +78,6 @@ fn log10(n: u128) -> usize {
}

struct Metric {
name: &'static str,
name: String,
duration: Duration,
}
2 changes: 1 addition & 1 deletion godot-codegen/src/api_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct Class {
pub is_refcounted: bool,
pub is_instantiable: bool,
pub inherits: Option<String>,
// pub api_type: String,
pub api_type: String,
pub constants: Option<Vec<ClassConstant>>,
pub enums: Option<Vec<Enum>>,
pub methods: Option<Vec<ClassMethod>>,
Expand Down
Loading