mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
text: [API] reduce size of Glyph.Runes to uint16
This shrinks text.Glyph from 72B to 58B. LabelStatic/1000runes-RTL-arabic-32 63.62µ ± 0% 62.05µ ± 0% -2.47% (p=0.002 n=6) Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
+7
-7
@@ -51,9 +51,9 @@ func TestWrappingTruncation(t *testing.T) {
|
||||
for g, ok := cache.NextGlyph(); ok; g, ok = cache.NextGlyph() {
|
||||
glyphs = append(glyphs, g)
|
||||
if g.Flags&FlagTruncator != 0 && g.Flags&FlagClusterBreak != 0 {
|
||||
truncatedRunes += g.Runes
|
||||
truncatedRunes += int(g.Runes)
|
||||
} else {
|
||||
untruncatedRunes += g.Runes
|
||||
untruncatedRunes += int(g.Runes)
|
||||
}
|
||||
if g.Flags&FlagLineBreak != 0 {
|
||||
lineCount++
|
||||
@@ -117,9 +117,9 @@ func TestWrappingForcedTruncation(t *testing.T) {
|
||||
for g, ok := cache.NextGlyph(); ok; g, ok = cache.NextGlyph() {
|
||||
glyphs = append(glyphs, g)
|
||||
if g.Flags&FlagTruncator != 0 && g.Flags&FlagClusterBreak != 0 {
|
||||
truncatedRunes += g.Runes
|
||||
truncatedRunes += int(g.Runes)
|
||||
} else {
|
||||
untruncatedRunes += g.Runes
|
||||
untruncatedRunes += int(g.Runes)
|
||||
}
|
||||
if g.Flags&FlagLineBreak != 0 {
|
||||
lineCount++
|
||||
@@ -191,9 +191,9 @@ func TestShapingNewlineHandling(t *testing.T) {
|
||||
for g, ok := cache.NextGlyph(); ok; g, ok = cache.NextGlyph() {
|
||||
glyphs = append(glyphs, g)
|
||||
if g.Flags&FlagTruncator == 0 {
|
||||
runes += g.Runes
|
||||
runes += int(g.Runes)
|
||||
} else {
|
||||
truncated += g.Runes
|
||||
truncated += int(g.Runes)
|
||||
}
|
||||
}
|
||||
if expected := len([]rune(tc.textInput)) - tc.expectedTruncated; expected != runes {
|
||||
@@ -571,7 +571,7 @@ func TestShapeStringRuneAccounting(t *testing.T) {
|
||||
}
|
||||
totalRunes := 0
|
||||
for _, g := range glyphs {
|
||||
totalRunes += g.Runes
|
||||
totalRunes += int(g.Runes)
|
||||
}
|
||||
if inputRunes := len([]rune(tc.input)); totalRunes != inputRunes {
|
||||
t.Errorf("input contained %d runes, but glyphs contained %d", inputRunes, totalRunes)
|
||||
|
||||
Reference in New Issue
Block a user