mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Fragment debug_id u16 only exists in debug, prod will format mem address
This commit is contained in:
parent
d890453f78
commit
43396c027d
2 changed files with 62 additions and 12 deletions
|
@ -15,10 +15,12 @@ use std::borrow::ToOwned;
|
|||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
#[cfg(debug_assertions)]
|
||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
||||
|
||||
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
static DEBUG_ID_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
pub struct Scope;
|
||||
|
@ -96,6 +98,7 @@ impl Drop for Scope {
|
|||
/// Generate a unique ID. This is used for items such as Fragment
|
||||
/// which are often reallocated but represent essentially the
|
||||
/// same data.
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn generate_unique_debug_id() -> u16 {
|
||||
DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue