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

Remove accidental ::{{closure}} suffix from all profile_function scopes #175

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [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

Expand Down
9 changes: 8 additions & 1 deletion puffin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ pub fn type_name_of<T>(_: 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 {
() => {{
Expand Down Expand Up @@ -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)
Expand Down
Loading