followup #18318: simplify dollarImpl and add a test (#18330)

This commit is contained in:
Timothee Cour 2021-06-22 21:42:39 -07:00 • committed by GitHub
commit 5badeea170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View file

@ -7,15 +7,8 @@ proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.}
## spelling `toString`:idx:.
template dollarImpl(x: uint | uint64, result: var string) =
type destTyp = typeof(x)
if x == 0:
return "0"
elif x == 1:
return "1"
let length = digits10(x)
setLen(result, length)
numToString(result, x, length)
when defined(js):