Optimize .count() > 1 check (#1053)

This can be trivially optimized to `.nth(1).is_some()` which obviates evaluating every element in the iterator.
This commit is contained in:
Matt Fellenz 2023-05-01 04:29:59 -07:00 committed by GitHub
parent 407d8a3ab2
commit b41cce191c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,7 +155,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
FrameFragment::new(self, frame).into()
} else {
// Anything else is handled by Typst's standard text layout.
let spaced = text.graphemes(true).count() > 1;
let spaced = text.graphemes(true).nth(1).is_some();
let mut style = self.style;
if self.style.italic == Smart::Auto {
style = style.with_italic(false);