- Notifications
You must be signed in to change notification settings - Fork61
Increase the #[inline] opportunities - 15-40% performance improvements#100
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -228,6 +228,7 @@ enum PairResult { | ||
Emoji, // a break if preceded by emoji base and (Extend)* | ||
} | ||
#[inline] | ||
fn check_pair(before: GraphemeCat, after: GraphemeCat) -> PairResult { | ||
use crate::tables::grapheme::GraphemeCat::*; | ||
use self::PairResult::*; | ||
@@ -407,6 +408,7 @@ impl GraphemeCursor { | ||
} | ||
} | ||
#[inline] | ||
fn decide(&mut self, is_break: bool) { | ||
self.state = if is_break { | ||
GraphemeState::Break | ||
@@ -415,11 +417,13 @@ impl GraphemeCursor { | ||
}; | ||
} | ||
#[inline] | ||
fn decision(&mut self, is_break: bool) -> Result<bool, GraphemeIncomplete> { | ||
self.decide(is_break); | ||
Ok(is_break) | ||
} | ||
#[inline] | ||
fn is_boundary_result(&self) -> Result<bool, GraphemeIncomplete> { | ||
if self.state == GraphemeState::Break { | ||
Ok(true) | ||
@@ -432,6 +436,7 @@ impl GraphemeCursor { | ||
} | ||
} | ||
#[inline] | ||
fn handle_regional(&mut self, chunk: &str, chunk_start: usize) { | ||
use crate::tables::grapheme as gr; | ||
let mut ris_count = self.ris_count.unwrap_or(0); | ||
@@ -452,6 +457,7 @@ impl GraphemeCursor { | ||
self.state = GraphemeState::Regional; | ||
} | ||
#[inline] | ||
fn handle_emoji(&mut self, chunk: &str, chunk_start: usize) { | ||
use crate::tables::grapheme as gr; | ||
let mut iter = chunk.chars().rev(); | ||
@@ -482,6 +488,7 @@ impl GraphemeCursor { | ||
self.state = GraphemeState::Emoji; | ||
} | ||
#[inline] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. this should probably go below the docs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thanks. I thought I saw this pattern somewhere else in the crate and decided to follow. Will submit a follow-up PR that moves all of them below the docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. sounds good! | ||
/// Determine whether the current cursor location is a grapheme cluster boundary. | ||
/// Only a part of the string need be supplied. If `chunk_start` is nonzero or | ||
/// the length of `chunk` is not equal to `len` on creation, then this method | ||
@@ -563,6 +570,7 @@ impl GraphemeCursor { | ||
} | ||
} | ||
#[inline] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. same | ||
/// Find the next boundary after the current cursor position. Only a part of | ||
/// the string need be supplied. If the chunk is incomplete, then this | ||
/// method might return `GraphemeIncomplete::PreContext` or | ||