Skip to content

Commit

Permalink
Merge pull request #387 from godot-rust/qol/cached-function-pointers
Browse files Browse the repository at this point in the history
Cache function pointers in global tables
  • Loading branch information
Bromeon authored Sep 5, 2023
2 parents 82bcf30 + 0c89812 commit 9e6fe56
Show file tree
Hide file tree
Showing 17 changed files with 1,361 additions and 454 deletions.
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

0 comments on commit 9e6fe56

Please sign in to comment.