revert stdlib changes which are not required anymore
This commit is contained in:
parent
66f18037b3
commit
484548c784
6 changed files with 20 additions and 21 deletions
|
|
@ -371,8 +371,9 @@ proc map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
|
|||
b = map(a, proc(x: int): string = $x)
|
||||
assert b == @["1", "2", "3", "4"]
|
||||
|
||||
result = newSeqOfCap[S](s.len)
|
||||
for elem in s: result.add op(elem)
|
||||
newSeq(result, s.len)
|
||||
for i in 0 ..< s.len:
|
||||
result[i] = op(s[i])
|
||||
|
||||
proc apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
|
||||
{.inline.} =
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ template withValue*[A, B](t: var SharedTable[A, B], key: A,
|
|||
try:
|
||||
var hc: Hash
|
||||
var index = rawGet(t, key, hc)
|
||||
if index >= 0:
|
||||
let hasKey = index >= 0
|
||||
if hasKey:
|
||||
var value {.inject.} = addr(t.data[index].val)
|
||||
body
|
||||
finally:
|
||||
|
|
@ -103,7 +104,8 @@ template withValue*[A, B](t: var SharedTable[A, B], key: A,
|
|||
try:
|
||||
var hc: Hash
|
||||
var index = rawGet(t, key, hc)
|
||||
if index >= 0:
|
||||
let hasKey = index >= 0
|
||||
if hasKey:
|
||||
var value {.inject.} = addr(t.data[index].val)
|
||||
body1
|
||||
else:
|
||||
|
|
@ -117,13 +119,13 @@ proc mget*[A, B](t: var SharedTable[A, B], key: A): var B =
|
|||
withLock t:
|
||||
var hc: Hash
|
||||
var index = rawGet(t, key, hc)
|
||||
if index >= 0:
|
||||
result = t.data[index].val
|
||||
let hasKey = index >= 0
|
||||
if hasKey: result = t.data[index].val
|
||||
if not hasKey:
|
||||
when compiles($key):
|
||||
raise newException(KeyError, "key not found: " & $key)
|
||||
else:
|
||||
when compiles($key):
|
||||
raise newException(KeyError, "key not found: " & $key)
|
||||
else:
|
||||
raise newException(KeyError, "key not found")
|
||||
raise newException(KeyError, "key not found")
|
||||
|
||||
proc mgetOrPut*[A, B](t: var SharedTable[A, B], key: A, val: B): var B =
|
||||
## retrieves value at ``t[key]`` or puts ``val`` if not present, either way
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue