-
Notifications
You must be signed in to change notification settings - Fork 60
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
/// 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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good!