summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Fellenz <matt@felle.nz>2023-05-01 04:29:59 -0700
committerGitHub <noreply@github.com>2023-05-01 13:29:59 +0200
commitb41cce191ca792e4622d859f3f8b84d45f9e070c (patch)
tree2d05e054c2dd6bd5712f7887042f1467f1714722
parent407d8a3ab291c953d9dec826015099dd0d18749e (diff)
Optimize `.count() > 1` check (#1053)
This can be trivially optimized to `.nth(1).is_some()` which obviates evaluating every element in the iterator.
-rw-r--r--library/src/math/ctx.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/src/math/ctx.rs b/library/src/math/ctx.rs
index 562f0ba9..a6487476 100644
--- a/library/src/math/ctx.rs
+++ b/library/src/math/ctx.rs
@@ -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);