Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize `TextRun::advance_for_range`. #8990

Merged
merged 3 commits into from Dec 17, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

util: Inline trivial range constructors.

These were showing up in the profile.
  • Loading branch information
pcwalton committed Dec 15, 2015
commit 6f2aa54120d980e9bb1d2c05f163e1971fc8a30a
@@ -22,15 +22,23 @@ pub trait Int:
fn from_usize(n: usize) -> Option<Self>;
}
impl Int for isize {
#[inline]
fn zero() -> isize { 0 }
#[inline]
fn one() -> isize { 1 }
#[inline]
fn max_value() -> isize { ::std::isize::MAX }
#[inline]
fn from_usize(n: usize) -> Option<isize> { num_lib::NumCast::from(n) }
}
impl Int for usize {
#[inline]
fn zero() -> usize { 0 }
#[inline]
fn one() -> usize { 1 }
#[inline]
fn max_value() -> usize { ::std::usize::MAX }
#[inline]
fn from_usize(n: usize) -> Option<usize> { Some(n) }
}

@@ -88,9 +96,13 @@ macro_rules! int_range_index {
}

impl $crate::range::Int for $Self_ {
#[inline]
fn zero() -> $Self_ { $Self_($crate::range::Int::zero()) }
#[inline]
fn one() -> $Self_ { $Self_($crate::range::Int::one()) }
#[inline]
fn max_value() -> $Self_ { $Self_($crate::range::Int::max_value()) }
#[inline]
fn from_usize(n: usize) -> Option<$Self_> { $crate::range::Int::from_usize(n).map($Self_) }
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.