about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-13 21:41:44 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-13 21:45:23 +0200
commitdd2490ca26d620de0d5cbddc99d22bccd73e3d2c (patch)
tree7944158d60e42b905a9f8ce3b102e838c3277105 /src/utils
parent8271d05a889ad0ca35148847d06e6503ad5c121b (diff)
downloadchawan-dd2490ca26d620de0d5cbddc99d22bccd73e3d2c.tar.gz
twtstr: simplify
* remove unused function isAlphaAscii
* swap pushHex for less casting
* remove == overload for char/rune (we did not really use it anyway)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index d7b8139a..e2f2ee6c 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -117,9 +117,6 @@ func normalizeLocale*(s: string): string =
 func isAscii*(r: Rune): bool =
   return cast[uint32](r) < 128
 
-func `==`*(r: Rune, c: char): bool {.inline.} =
-  return Rune(c) == r
-
 func startsWithNoCase*(str, prefix: string): bool =
   if str.len < prefix.len: return false
   # prefix.len is always lower
@@ -159,9 +156,12 @@ func isAscii*(s: string): bool =
 
 const HexCharsUpper = "0123456789ABCDEF"
 const HexCharsLower = "0123456789abcdef"
+func pushHex*(buf: var string, u: uint8) =
+  buf &= HexCharsUpper[u shr 4]
+  buf &= HexCharsUpper[u and 0xF]
+
 func pushHex*(buf: var string, c: char) =
-  buf &= HexCharsUpper[(uint8(c) shr 4)]
-  buf &= HexCharsUpper[(uint8(c) and 0xF)]
+  buf.pushHex(cast[uint8](c))
 
 func toHexLower*(u: uint16): string =
   var x = u
@@ -179,15 +179,9 @@ func toHexLower*(u: uint16): string =
     x = x shr 4
   return s
 
-func pushHex*(buf: var string, i: uint8) =
-  buf.pushHex(cast[char](i))
-
 func equalsIgnoreCase*(s1, s2: string): bool {.inline.} =
   return s1.cmpIgnoreCase(s2) == 0
 
-func isAlphaAscii*(r: Rune): bool =
-  return int(r) < 256 and isAlphaAscii(char(r))
-
 func isDigitAscii*(r: Rune): bool =
   return int(r) < 256 and isDigit(char(r))