mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 02:21:43 +00:00
fixes merge conflict
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -265,7 +265,7 @@ proc arcsech*[T: float32|float64](x: T): T = arccosh(1.0 / x)
|
||||
proc arccsch*[T: float32|float64](x: T): T = arcsinh(1.0 / x)
|
||||
## Computes the inverse hyperbolic cosecant of `x`
|
||||
|
||||
const windowsCC89 = defined(windows) and (defined(vcc) or defined(bcc))
|
||||
const windowsCC89 = defined(windows) and defined(bcc)
|
||||
|
||||
when not defined(JS): # C
|
||||
proc hypot*(x, y: float32): float32 {.importc: "hypotf", header: "<math.h>".}
|
||||
|
||||
@@ -37,8 +37,6 @@ type
|
||||
length: int
|
||||
data: string # != nil if a leaf
|
||||
|
||||
proc isConc(r: Rope): bool {.inline.} = return r.length > 0
|
||||
|
||||
# Note that the left and right pointers are not needed for leafs.
|
||||
# Leaves have relatively high memory overhead (~30 bytes on a 32
|
||||
# bit machine) and we produce many of them. This is why we cache and
|
||||
@@ -50,12 +48,12 @@ proc isConc(r: Rope): bool {.inline.} = return r.length > 0
|
||||
proc len*(a: Rope): int {.rtl, extern: "nro$1".} =
|
||||
## the rope's length
|
||||
if a == nil: result = 0
|
||||
else: result = abs a.length
|
||||
else: result = a.length
|
||||
|
||||
proc newRope(): Rope = new(result)
|
||||
proc newRope(data: string): Rope =
|
||||
new(result)
|
||||
result.length = -len(data)
|
||||
result.length = len(data)
|
||||
result.data = data
|
||||
|
||||
var
|
||||
@@ -170,7 +168,9 @@ proc `&`*(a, b: Rope): Rope {.rtl, extern: "nroConcRopeRope".} =
|
||||
result = a
|
||||
else:
|
||||
result = newRope()
|
||||
result.length = abs(a.length) + abs(b.length)
|
||||
result.length = a.length + b.length
|
||||
result.left = a
|
||||
result.right = b
|
||||
|
||||
proc `&`*(a: Rope, b: string): Rope {.rtl, extern: "nroConcRopeStr".} =
|
||||
## the concatenation operator for ropes.
|
||||
@@ -199,11 +199,11 @@ proc `[]`*(r: Rope, i: int): char {.rtl, extern: "nroCharAt".} =
|
||||
var j = i
|
||||
if x == nil: return
|
||||
while true:
|
||||
if not isConc(x):
|
||||
if x.data.len <% j: return x.data[j]
|
||||
if x != nil and x.data.len > 0:
|
||||
if j < x.data.len: return x.data[j]
|
||||
return '\0'
|
||||
else:
|
||||
if x.left.len >% j:
|
||||
if x.left.length > j:
|
||||
x = x.left
|
||||
else:
|
||||
x = x.right
|
||||
@@ -215,7 +215,8 @@ iterator leaves*(r: Rope): string =
|
||||
var stack = @[r]
|
||||
while stack.len > 0:
|
||||
var it = stack.pop
|
||||
while isConc(it):
|
||||
while it.left != nil:
|
||||
assert(it.right != nil)
|
||||
stack.add(it.right)
|
||||
it = it.left
|
||||
assert(it != nil)
|
||||
|
||||
@@ -423,18 +423,14 @@ proc toUnix*(t: Time): int64 {.benign, tags: [], raises: [], noSideEffect.} =
|
||||
## Convert ``t`` to a unix timestamp (seconds since ``1970-01-01T00:00:00Z``).
|
||||
runnableExamples:
|
||||
doAssert fromUnix(0).toUnix() == 0
|
||||
|
||||
t.seconds
|
||||
|
||||
proc fromWinTime*(win: int64): Time =
|
||||
## Convert a Windows file time (100-nanosecond intervals since ``1601-01-01T00:00:00Z``)
|
||||
## to a ``Time``.
|
||||
let hnsecsSinceEpoch = (win - epochDiff)
|
||||
var seconds = hnsecsSinceEpoch div rateDiff
|
||||
var nanos = ((hnsecsSinceEpoch mod rateDiff) * 100).int
|
||||
if nanos < 0:
|
||||
nanos += convert(Seconds, Nanoseconds, 1)
|
||||
seconds -= 1
|
||||
const hnsecsPerSec = convert(Seconds, Nanoseconds, 1) div 100
|
||||
let nanos = floorMod(win, hnsecsPerSec) * 100
|
||||
let seconds = floorDiv(win - epochDiff, hnsecsPerSec)
|
||||
result = initTime(seconds, nanos)
|
||||
|
||||
proc toWinTime*(t: Time): int64 =
|
||||
|
||||
@@ -3767,23 +3767,23 @@ template assert*(cond: bool, msg = "") =
|
||||
## The compiler may not generate any code at all for ``assert`` if it is
|
||||
## advised to do so through the ``-d:release`` or ``--assertions:off``
|
||||
## `command line switches <nimc.html#command-line-switches>`_.
|
||||
# NOTE: `true` is correct here; --excessiveStackTrace:on will control whether
|
||||
# or not to output full paths.
|
||||
bind instantiationInfo
|
||||
mixin failedAssertImpl
|
||||
when compileOption("assertions"):
|
||||
{.line.}:
|
||||
{.line: instantiationInfo(fullPaths = true).}:
|
||||
when compileOption("assertions"):
|
||||
if not cond: failedAssertImpl(astToStr(cond) & ' ' & msg)
|
||||
|
||||
template doAssert*(cond: bool, msg = "") =
|
||||
## same as `assert` but is always turned on and not affected by the
|
||||
## ``--assertions`` command line switch.
|
||||
bind instantiationInfo
|
||||
# NOTE: `true` is correct here; --excessiveStackTrace:on will control whether
|
||||
# or not to output full paths.
|
||||
{.line: instantiationInfo(-1, true).}:
|
||||
if not cond:
|
||||
raiseAssert(astToStr(cond) & ' ' &
|
||||
instantiationInfo(-1, false).fileName & '(' &
|
||||
$instantiationInfo(-1, false).line & ") " & msg)
|
||||
bind instantiationInfo
|
||||
mixin failedAssertImpl
|
||||
{.line: instantiationInfo(fullPaths = true).}:
|
||||
if not cond: failedAssertImpl(astToStr(cond) & ' ' & msg)
|
||||
|
||||
iterator items*[T](a: seq[T]): T {.inline.} =
|
||||
## iterates over each item of `a`.
|
||||
|
||||
Reference in New Issue
Block a user