1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Add nightly feature, use for unlikely intrinsic

This commit is contained in:
Manish Goregaokar 2017-01-06 16:32:29 -08:00
parent fbeded8ac5
commit 49187d53f2
5 changed files with 13 additions and 3 deletions

View file

@ -35,6 +35,7 @@ default = ["err-println"]
# Enabling this feature makes shaders automatically reload when changed # Enabling this feature makes shaders automatically reload when changed
live-shader-reload = [] live-shader-reload = []
err-println = [] err-println = []
nightly = []
[build-dependencies] [build-dependencies]
gl_generator = "0.5" gl_generator = "0.5"

View file

@ -150,7 +150,7 @@ impl<T> Grid<T> {
/// better error messages by doing the bounds checking ourselves. /// better error messages by doing the bounds checking ourselves.
#[inline] #[inline]
pub fn swap_lines(&mut self, src: index::Line, dst: index::Line) { pub fn swap_lines(&mut self, src: index::Line, dst: index::Line) {
use std::intrinsics::unlikely; use util::unlikely;
unsafe { unsafe {
// check that src/dst are in bounds. Since index::Line newtypes usize, // check that src/dst are in bounds. Since index::Line newtypes usize,

View file

@ -20,7 +20,7 @@
#![cfg_attr(feature = "clippy", deny(if_not_else))] #![cfg_attr(feature = "clippy", deny(if_not_else))]
#![cfg_attr(feature = "clippy", deny(wrong_pub_self_convention))] #![cfg_attr(feature = "clippy", deny(wrong_pub_self_convention))]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
#![feature(core_intrinsics)] #![cfg_attr(feature = "nightly", feature(core_intrinsics))]
#![feature(proc_macro)] #![feature(proc_macro)]

View file

@ -630,7 +630,7 @@ impl ansi::Handler for Term {
} }
unsafe { unsafe {
if ::std::intrinsics::unlikely(self.cursor.line == self.grid.num_lines()) { if ::util::unlikely(self.cursor.line == self.grid.num_lines()) {
panic!("cursor fell off grid"); panic!("cursor fell off grid");
} }
} }

View file

@ -13,6 +13,15 @@
// limitations under the License. // limitations under the License.
use std::cmp; 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 /// Threading utilities
pub mod thread { pub mod thread {
/// Like `thread::spawn`, but with a `name` argument /// Like `thread::spawn`, but with a `name` argument