diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b6e6a6..30c0cf88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,16 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate + +- [PR#175](https://github.com/EmbarkStudios/puffin/pull/175) Remove accidental `::{{closure}}` suffix from all `profile_function` scopes. + ## [0.18.0] - 2023-11-21 -## [0.17.1] - 2023-11-20 -- [PR#165](https://github.com/EmbarkStudios/puffin/issues/165) Faster profiling, add line numbers, better paths, and better function names +- [PR#165](https://github.com/EmbarkStudios/puffin/pull/165) Faster profiling, add line numbers, better paths, and better function names + +## [0.17.1] - 2023-11-20 - YANKED + +- Accidentally introduced a breaking change in [PR#165](https://github.com/EmbarkStudios/puffin/pull/165) ## [0.17.0] - 2023-09-28 -- [PR#140](https://github.com/EmbarkStudios/puffin/issues/140) Remove imgui support for +- [PR#140](https://github.com/EmbarkStudios/puffin/pull/140) Remove imgui support for - [PR#158](https://github.com/EmbarkStudios/puffin/pull/158) Remove file I/O from -- [PR#157](https://github.com/EmbarkStudios/puffin/issues/157) Remove `instant` dependency when not building for web +- [PR#157](https://github.com/EmbarkStudios/puffin/pull/157) Remove `instant` dependency when not building for web ## [0.16.0] - 2023-05-24 diff --git a/puffin/src/lib.rs b/puffin/src/lib.rs index dbcf7770..5e016a2a 100644 --- a/puffin/src/lib.rs +++ b/puffin/src/lib.rs @@ -619,6 +619,7 @@ pub fn type_name_of(_: T) -> &'static str { } /// Returns the name of the calling function without a long module path prefix. +#[doc(hidden)] #[macro_export] macro_rules! current_function_name { () => {{ @@ -825,7 +826,13 @@ macro_rules! profile_function { // SAFETY: accessing the statics is safe because it is done in cojunction with `std::sync::Once`` let (function_name, location) = unsafe { _INITITIALIZED.call_once(|| { - _FUNCTION_NAME = $crate::current_function_name!().leak(); + let function_name = $crate::current_function_name!(); + + // We call `current_function_name` from a closure, so we need to strip that from the output. + // We only strip it once though, because if the user calls `profile_function!` from within a closure, they probably want to know it. + let function_name = function_name.strip_suffix("::{{closure}}").unwrap_or(function_name.as_ref()); + + _FUNCTION_NAME = function_name.to_owned().leak(); _LOCATION = format!("{}:{}", $crate::current_file_name!(), line!()).leak(); }); (_FUNCTION_NAME, _LOCATION)