mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Make profiling API a bit harder to misuse
This commit is contained in:
@@ -518,11 +518,7 @@ fn throwing_main() -> i32 {
|
||||
// TODO(MSRV>=1.88): feature(let_chains)
|
||||
if let Some(path) = &opts.profile_startup_output {
|
||||
if opts.profile_startup_output != opts.profile_output {
|
||||
parser.emit_profiling(path);
|
||||
|
||||
// If we are profiling both, ensure the startup data only
|
||||
// ends up in the startup file.
|
||||
parser.clear_profiling();
|
||||
parser.flush_profiling(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,7 +617,7 @@ fn throwing_main() -> i32 {
|
||||
);
|
||||
|
||||
if let Some(profile_output) = opts.profile_output {
|
||||
parser.emit_profiling(&profile_output);
|
||||
parser.flush_profiling(&profile_output);
|
||||
}
|
||||
|
||||
history::save_all();
|
||||
|
||||
@@ -1119,13 +1119,8 @@ pub fn profile_items_mut(&self) -> RefMut<'_, Vec<ProfileItem>> {
|
||||
self.profile_items.borrow_mut()
|
||||
}
|
||||
|
||||
/// Remove the profiling items.
|
||||
pub fn clear_profiling(&self) {
|
||||
self.profile_items.borrow_mut().clear();
|
||||
}
|
||||
|
||||
/// Output profiling data to the given filename.
|
||||
pub fn emit_profiling(&self, path: &OsStr) {
|
||||
/// Flush profiling data to the given filename.
|
||||
pub fn flush_profiling(&self, path: &OsStr) {
|
||||
// Save profiling information. OK to not use CLO_EXEC here because this is called while fish is
|
||||
// exiting (and hence will not fork).
|
||||
let mut f = match std::fs::File::create(path) {
|
||||
@@ -1142,7 +1137,9 @@ pub fn emit_profiling(&self, path: &OsStr) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
print_profile(&self.profile_items.borrow(), &mut f);
|
||||
let mut profile_items = self.profile_items.borrow_mut();
|
||||
print_profile(&profile_items, &mut f);
|
||||
profile_items.clear();
|
||||
}
|
||||
|
||||
pub fn get_backtrace(&self, src: &wstr, errors: &ParseErrorList) -> WString {
|
||||
|
||||
Reference in New Issue
Block a user