1
Fork 0

Remove likely! and unlikely! macro from compiler

This commit is contained in:
Gary Guo 2022-05-31 22:42:42 +01:00
parent aaf100597c
commit 8b7299dd12
5 changed files with 13 additions and 31 deletions

View file

@ -11,7 +11,6 @@
#![feature(associated_type_bounds)]
#![feature(auto_traits)]
#![feature(control_flow_enum)]
#![feature(core_intrinsics)]
#![feature(extend_one)]
#![feature(let_else)]
#![feature(hash_raw_entry)]
@ -44,26 +43,6 @@ pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
f()
}
#[macro_export]
macro_rules! likely {
($e:expr) => {
match $e {
#[allow(unused_unsafe)]
e => unsafe { std::intrinsics::likely(e) },
}
};
}
#[macro_export]
macro_rules! unlikely {
($e:expr) => {
match $e {
#[allow(unused_unsafe)]
e => unsafe { std::intrinsics::unlikely(e) },
}
};
}
pub mod base_n;
pub mod binary_search_util;
pub mod captures;

View file

@ -195,6 +195,7 @@ impl SelfProfilerRef {
F: for<'a> FnOnce(&'a SelfProfiler) -> TimingGuard<'a>,
{
#[inline(never)]
#[cold]
fn cold_call<F>(profiler_ref: &SelfProfilerRef, f: F) -> TimingGuard<'_>
where
F: for<'a> FnOnce(&'a SelfProfiler) -> TimingGuard<'a>,
@ -203,7 +204,7 @@ impl SelfProfilerRef {
f(&**profiler)
}
if unlikely!(self.event_filter_mask.contains(event_filter)) {
if self.event_filter_mask.contains(event_filter) {
cold_call(self, f)
} else {
TimingGuard::none()