Skip to content

Commit ffc8c1d

Browse files
committed
use sync.OnceValue
1 parent bcc28aa commit ffc8c1d

File tree

2 files changed

+198
-194
lines changed

2 files changed

+198
-194
lines changed

modules/badge/badge.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ func GenerateBadge(label, message, color string) Badge {
9393

9494
func calculateTextWidth(text string) int {
9595
width := 0
96-
96+
widthData := DejaVuGlyphWidthData()
9797
for _, char := range strings.TrimSpace(text) {
98-
charWidth, ok := DejaVuGlyphWidthData[char]
98+
charWidth, ok := widthData[char]
9999
if !ok {
100100
// use the width of 'm' in case of missing glyph width data for a printable character
101101
if unicode.IsPrint(char) {
102-
charWidth = DejaVuGlyphWidthData['m']
102+
charWidth = widthData['m']
103103
} else {
104104
charWidth = 0
105105
}

0 commit comments

Comments
 (0)