From edefd68a320ac6903deb2012ebb5568f3cfd44dd Mon Sep 17 00:00:00 2001 From: Jason McNeil Date: Mon, 25 Mar 2024 13:06:15 -0300 Subject: [PATCH] refactor: DRY IfToLower and IfToUpper --- strings.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/strings.go b/strings.go index c47d0bc..47af92d 100644 --- a/strings.go +++ b/strings.go @@ -46,13 +46,7 @@ func IfToLower(s string) string { if !hasUpper { return s } - res := make([]byte, len(s)) - copy(res, s) - for i := 0; i < len(res); i++ { - res[i] = toLowerTable[res[i]] - } - - return UnsafeString(res) + return ToLower(s) } // IfToUpper returns an uppercase version of the input ASCII string. @@ -75,11 +69,5 @@ func IfToUpper(s string) string { if !hasLower { return s } - res := make([]byte, len(s)) - copy(res, s) - for i := 0; i < len(res); i++ { - res[i] = toUpperTable[res[i]] - } - - return UnsafeString(res) + return ToUpper(s) }