From c2327484006ef3b65d2c2b81f712d7a821393a46 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Mon, 22 May 2023 09:24:28 +0800 Subject: [PATCH] This avoid unnecessary byte/string conversion (#1541) Signed-off-by: Eng Zer Jun --- numfmt.go | 2 +- table.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/numfmt.go b/numfmt.go index cea63a1a..57aa8c8e 100644 --- a/numfmt.go +++ b/numfmt.go @@ -1220,7 +1220,7 @@ func printCommaSep(text string) string { if i > 0 && (length-i)%3 == 0 { target.WriteString(",") } - target.WriteString(string(text[i])) + target.WriteByte(text[i]) } if len(subStr) == 2 { target.WriteString(".") diff --git a/table.go b/table.go index 8b375a8a..094f7659 100644 --- a/table.go +++ b/table.go @@ -490,7 +490,7 @@ func (f *File) parseFilterExpression(expression string, tokens []string) ([]int, // expressions). conditional := 0 c := tokens[3] - if conditionFormat.Match([]byte(c)) { + if conditionFormat.MatchString(c) { conditional = 1 } expression1, token1, err := f.parseFilterTokens(expression, tokens[:3]) @@ -538,7 +538,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str } token := tokens[2] // Special handling for Blanks/NonBlanks. - re := blankFormat.Match([]byte(strings.ToLower(token))) + re := blankFormat.MatchString((strings.ToLower(token))) if re { // Only allow Equals or NotEqual in this context. if operator != 2 && operator != 5 { @@ -563,7 +563,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str } // If the string token contains an Excel match character then change the // operator type to indicate a non "simple" equality. - re = matchFormat.Match([]byte(token)) + re = matchFormat.MatchString(token) if operator == 2 && re { operator = 22 }