Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement a special-case lookup for ascii grapheme categories.#79

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

Merged
Manishearth merged 2 commits intounicode-rs:masterfromcessen:ascii_grapheme_optimization
Feb 14, 2020
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletionssrc/grapheme.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -284,12 +284,30 @@ impl GraphemeCursor {

fn grapheme_category(&mut self, ch: char) -> GraphemeCat {
use tables::grapheme as gr;
// If this char isn't within the cached range, update the cache to the
// range that includes it.
if (ch as u32) < self.grapheme_cat_cache.0 || (ch as u32) > self.grapheme_cat_cache.1 {
self.grapheme_cat_cache = gr::grapheme_category(ch);
use tables::grapheme::GraphemeCat::*;

if ch <= '\u{7e}' {
// Special-case optimization for ascii, except U+007F. This
// improves performance even for many primarily non-ascii texts,
// due to use of punctuation and white space characters from the
// ascii range.
if ch >= '\u{20}' {
GC_Any
} else if ch == '\n' {
GC_LF
} else if ch == '\r' {
GC_CR
} else {
GC_Control
}
} else {
// If this char isn't within the cached range, update the cache to the
// range that includes it.
if (ch as u32) < self.grapheme_cat_cache.0 || (ch as u32) > self.grapheme_cat_cache.1 {
self.grapheme_cat_cache = gr::grapheme_category(ch);
}
self.grapheme_cat_cache.2
}
self.grapheme_cat_cache.2
}

// Not sure I'm gonna keep this, the advantage over new() seems thin.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp