diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/pure/strutils.nim | 12 | ||||
-rwxr-xr-x | lib/system.nim | 6 | ||||
-rwxr-xr-x | lib/system/gc.nim | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index de555917c..382eece7b 100755 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -103,7 +103,7 @@ proc cmpIgnoreCase*(a, b: string): int {.noSideEffect, ## | 0 iff a == b ## | < 0 iff a < b ## | > 0 iff a > b - var i = 0 + var i = 0 var m = min(a.len, b.len) while i < m: result = ord(toLower(a[i])) - ord(toLower(b[i])) @@ -406,7 +406,7 @@ proc ParseInt*(s: string): int {.noSideEffect, procvar, ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseInt(s, result, 0) - if L != s.len or L == 0: + if L != s.len or L == 0: raise newException(EInvalidValue, "invalid integer: " & s) proc ParseBiggestInt*(s: string): biggestInt {.noSideEffect, procvar, @@ -414,7 +414,7 @@ proc ParseBiggestInt*(s: string): biggestInt {.noSideEffect, procvar, ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseBiggestInt(s, result, 0) - if L != s.len or L == 0: + if L != s.len or L == 0: raise newException(EInvalidValue, "invalid integer: " & s) proc ParseFloat*(s: string): float {.noSideEffect, procvar, @@ -423,7 +423,7 @@ proc ParseFloat*(s: string): float {.noSideEffect, procvar, ## a valid floating point number, `EInvalidValue` is raised. ``NAN``, ## ``INF``, ``-INF`` are also supported (case insensitive comparison). var L = parseutils.parseFloat(s, result, 0) - if L != s.len or L == 0: + if L != s.len or L == 0: raise newException(EInvalidValue, "invalid float: " & s) proc ParseHexInt*(s: string): int {.noSideEffect, procvar, @@ -952,7 +952,7 @@ type TFloatFormat* = enum ffDefault, ## use the shorter floating point notation ffDecimal, ## use decimal floating point notation - ffScientific ## use scientific notation (using ``e``) character + ffScientific ## use scientific notation (using ``e`` character) proc formatBiggestFloat*(f: BiggestFloat, format: TFloatFormat = ffDefault, precision = 16): string {.noSideEffect, @@ -1006,6 +1006,6 @@ when isMainModule: it goes""", 10, false) assert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001" assert formatBiggestFloat(0.00000000001, ffScientific, 1) == "1.0e-11" - + assert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c" diff --git a/lib/system.nim b/lib/system.nim index 8fc4493dd..6490ce416 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -650,13 +650,15 @@ proc setLen*[T](s: var seq[T], newlen: int) {. ## sets the length of `s` to `newlen`. ## ``T`` may be any sequence type. ## If the current length is greater than the new length, - ## ``s`` will be truncated. + ## ``s`` will be truncated. `s` cannot be nil! To initialize a sequence with + ## a size, use ``newSeq`` instead. proc setLen*(s: var string, newlen: int) {. magic: "SetLengthStr", noSideEffect.} ## sets the length of `s` to `newlen`. ## If the current length is greater than the new length, - ## ``s`` will be truncated. + ## ``s`` will be truncated. `s` cannot be nil! To initialize a string with + ## a size, use ``newString`` instead. proc newString*(len: int): string {. magic: "NewString", importc: "mnewString", noSideEffect.} diff --git a/lib/system/gc.nim b/lib/system/gc.nim index eb4811bf5..950b60c27 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -642,7 +642,11 @@ proc unmarkStackAndRegisters(gch: var TGcHeap) = var d = gch.decStack.d for i in 0..gch.decStack.len-1: assert isAllocatedPtr(allocator, d[i]) - decRef(d[i]) # OPT: cannot create a cycle! + # decRef(d[i]) inlined: cannot create a cycle + var c = d[i] + if atomicDec(c.refcount, rcIncrement) <% rcIncrement: + rtlAddZCT(c) + assert c.typ != nil gch.decStack.len = 0 proc collectCT(gch: var TGcHeap) = |