improvements to addInt and $ for integer types (#18592)
* improvements to $(SomeInteger) and addInt * remove mIntToStr, mInt64ToStr * improvements * fix tests/pragmas/tinjectstmt.nim; the diff is harmless, cgen code is identical with -d:danger or debug mode * rm tests/system/tstrmantle.nim * revert compiler/jsgen.nim for -d:nimVersion140
This commit is contained in:
parent
7b58dc2de0
commit
394f4ac7bb
12 changed files with 162 additions and 186 deletions
|
|
@ -2463,14 +2463,13 @@ when notJSnotNims:
|
|||
else:
|
||||
{.error: "Only closure iterator is allowed!".}
|
||||
|
||||
from std/private/digitsutils import addInt
|
||||
export addInt
|
||||
|
||||
when defined(js):
|
||||
include "system/jssys"
|
||||
include "system/reprjs"
|
||||
|
||||
when defined(js) or defined(nimscript):
|
||||
proc addInt*(result: var string; x: int64) =
|
||||
result.add $x
|
||||
|
||||
proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
|
||||
## A shorthand for `echo(errormsg); quit(errorcode)`.
|
||||
when defined(nimscript) or defined(js) or (hostOS == "standalone"):
|
||||
|
|
@ -2918,7 +2917,7 @@ proc addQuoted*[T](s: var string, x: T) =
|
|||
s.addEscapedChar(x)
|
||||
s.add("'")
|
||||
# prevent temporary string allocation
|
||||
elif T is SomeSignedInt:
|
||||
elif T is SomeInteger:
|
||||
s.addInt(x)
|
||||
elif T is SomeFloat:
|
||||
s.addFloat(x)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue