diff --git a/glyphs2fontir/src/glyphdata.rs b/glyphs2fontir/src/glyphdata.rs index de3598c9..24687a6f 100644 --- a/glyphs2fontir/src/glyphdata.rs +++ b/glyphs2fontir/src/glyphdata.rs @@ -4,6 +4,7 @@ use std::collections::HashSet; +// Do a quick (relative to large match on str) check to see if this might be a mark #[inline(always)] pub(crate) fn might_be_a_nonspacing_mark_name(name: &str) -> bool { // shove the first 4 chars into a u32 and see if they could possibly be a nonspacing mark @@ -698,6 +699,7 @@ pub(crate) fn is_nonspacing_mark_name(name: &str) -> bool { if name.len() > 35 || matches!(name.len(), 1 | 2) { return false; } + // fast exit: this can't possibly be a nonspacing mark if !might_be_a_nonspacing_mark_name(name) { return false; } diff --git a/resources/scripts/non_spacing_marks.py b/resources/scripts/non_spacing_marks.py index 10df9529..48aed5f3 100644 --- a/resources/scripts/non_spacing_marks.py +++ b/resources/scripts/non_spacing_marks.py @@ -82,6 +82,7 @@ def main(_): print(len(unique_prefix4s), "unique_prefix4s", sorted(unique_prefix4s)) f.write("\n") + f.write(" // Do a quick (relative to large match on str) check to see if this might be a mark\n") f.write("#[inline(always)]\n") f.write( "pub(crate) fn might_be_a_nonspacing_mark_name(name: &str) -> bool {\n" @@ -118,6 +119,7 @@ def main(_): # f.write(" return false;\n") # f.write(" };\n") + f.write(" // fast exit: this can't possibly be a nonspacing mark\n") f.write(" if !might_be_a_nonspacing_mark_name(name) {\n") f.write(" return false;\n") f.write(" }\n")