From 49187d53f2f8b7cfca9105c3fb00d7c29e2a457b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 16:32:29 -0800 Subject: Add `nightly` feature, use for `unlikely` intrinsic --- src/util.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/util.rs') diff --git a/src/util.rs b/src/util.rs index 44f7b3de..2e34b2a6 100644 --- a/src/util.rs +++ b/src/util.rs @@ -13,6 +13,15 @@ // limitations under the License. use std::cmp; +#[cfg(not(feature = "nightly"))] +#[inline(always)] +pub unsafe fn unlikely(x: bool) -> bool { + x +} + +#[cfg(feature = "nightly")] +pub use ::std::intrinsics::unlikely; + /// Threading utilities pub mod thread { /// Like `thread::spawn`, but with a `name` argument -- cgit From 4e1f4c8cd7180606156b71ad0222f60e4559f2b3 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Jan 2017 20:44:51 -0800 Subject: Clippy fixes! --- src/util.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/util.rs') diff --git a/src/util.rs b/src/util.rs index 2e34b2a6..ccb22cc9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -15,6 +15,7 @@ use std::cmp; #[cfg(not(feature = "nightly"))] #[inline(always)] +#[cfg_attr(feature = "clippy", allow(inline_always))] pub unsafe fn unlikely(x: bool) -> bool { x } -- cgit