widget: optimize processGlyph

processGlyph does not modify the value, so there's no reason to
return the struct.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2023-10-23 22:04:52 +03:00
committed by Chris Waldon
parent df8a8789a3
commit 48bd5952b1
3 changed files with 13 additions and 11 deletions
+8 -3
View File
@@ -492,14 +492,19 @@ func (e *textView) layoutText(lt *text.Shaper) {
it := textIterator{viewport: image.Rectangle{Max: image.Point{X: math.MaxInt, Y: math.MaxInt}}}
if lt != nil {
lt.Layout(e.params, r)
for glyph, ok := it.processGlyph(lt.NextGlyph()); ok; glyph, ok = it.processGlyph(lt.NextGlyph()) {
e.index.Glyph(glyph)
for {
g, ok := lt.NextGlyph()
if !it.processGlyph(g, ok) {
break
}
e.index.Glyph(g)
}
} else {
// Make a fake glyph for every rune in the reader.
b := bufio.NewReader(r)
for _, _, err := b.ReadRune(); err != io.EOF; _, _, err = b.ReadRune() {
g, _ := it.processGlyph(text.Glyph{Runes: 1, Flags: text.FlagClusterBreak}, true)
g := text.Glyph{Runes: 1, Flags: text.FlagClusterBreak}
_ = it.processGlyph(g, true)
e.index.Glyph(g)
}
}