Skip to content

Commit

Permalink
Use plain Vec for span stack since it just uses {push,pop}_back
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Dec 27, 2023
1 parent 6f0c24b commit 0f3f436
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tracing-tracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#![doc = include_str!("../FEATURES.mkd")]
#![cfg_attr(tracing_tracy_docs, feature(doc_auto_cfg))]

use std::{borrow::Cow, cell::UnsafeCell, collections::VecDeque, fmt::Write, mem};
use std::{borrow::Cow, cell::UnsafeCell, fmt::Write, mem};
use tracing_core::{
field::{Field, Visit},
span::{Attributes, Id, Record},
Expand All @@ -68,8 +68,7 @@ pub use client;

thread_local! {
/// A stack of spans currently active on the current thread.
static TRACY_SPAN_STACK: UnsafeCell<VecDeque<(Span, u64)>> =
const { UnsafeCell::new(VecDeque::new()) };
static TRACY_SPAN_STACK: VecCell<(Span, u64)> = const { VecCell::new() };
}

struct VecCell<T> {
Expand Down Expand Up @@ -267,12 +266,12 @@ where
};

TRACY_SPAN_STACK.with(|s| {
unsafe { &mut *s.get() }.push_back(stack_frame);
s.push(stack_frame);
});
}

fn on_exit(&self, id: &Id, _: Context<S>) {
let stack_frame = TRACY_SPAN_STACK.with(|s| unsafe { &mut *s.get() }.pop_back());
let stack_frame = TRACY_SPAN_STACK.with(|s| s.pop());

if let Some((span, span_id)) = stack_frame {
if id.into_u64() != span_id {
Expand Down

0 comments on commit 0f3f436

Please sign in to comment.