nice optimization, reuse cached
This commit is contained in:
parent
fa8f09e745
commit
852a02150c
|
@ -221,7 +221,7 @@ proc fromData*[K, V](data: openArray[byte]; pos: var int; output: var (Table[K,
|
||||||
proc fromData*[T](data: openArray[byte]; pos: var int; output: var ref T)
|
proc fromData*[T](data: openArray[byte]; pos: var int; output: var ref T)
|
||||||
proc fromData*[T](data: openArray[byte]; pos: var int; output: var Option[T])
|
proc fromData*[T](data: openArray[byte]; pos: var int; output: var Option[T])
|
||||||
proc fromData*[T: tuple](data: openArray[byte]; pos: var int; output: var T)
|
proc fromData*[T: tuple](data: openArray[byte]; pos: var int; output: var T)
|
||||||
proc fromData*[T: object](data: openArray[byte]; pos: var int; output: var T) {.nodestroy.}
|
proc fromData*[T: object](data: openArray[byte]; pos: var int; output: var T)
|
||||||
proc fromData*[T: distinct](data: openArray[byte]; pos: var int; output: var T) {.inline.}
|
proc fromData*[T: distinct](data: openArray[byte]; pos: var int; output: var T) {.inline.}
|
||||||
|
|
||||||
proc toData*(data: var openArray[byte]; pos: var int; input: string)
|
proc toData*(data: var openArray[byte]; pos: var int; input: string)
|
||||||
|
|
|
@ -585,7 +585,7 @@ template mutatorImpl*(target, mutator, typ: untyped) =
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
var pos = 1
|
var pos = 1
|
||||||
reset(cached)
|
#reset(cached)
|
||||||
fromData(data, pos, cached)
|
fromData(data, pos, cached)
|
||||||
|
|
||||||
proc setInput(data: openArray[byte]; len: int) {.inline.} =
|
proc setInput(data: openArray[byte]; len: int) {.inline.} =
|
||||||
|
@ -596,6 +596,7 @@ template mutatorImpl*(target, mutator, typ: untyped) =
|
||||||
copyMem(unsafeAddr data, addr buffer[0], len)
|
copyMem(unsafeAddr data, addr buffer[0], len)
|
||||||
|
|
||||||
proc clearBuffer() {.inline.} =
|
proc clearBuffer() {.inline.} =
|
||||||
|
reset(cached)
|
||||||
setLen(buffer, 1)
|
setLen(buffer, 1)
|
||||||
|
|
||||||
proc testOneInputImpl(data: openArray[byte]) =
|
proc testOneInputImpl(data: openArray[byte]) =
|
||||||
|
|
|
@ -48,7 +48,8 @@ proc byteSize[M, N: static[int]](x: Matrix32[M, N]): int {.inline.} =
|
||||||
result = M * N * sizeof(float32)
|
result = M * N * sizeof(float32)
|
||||||
|
|
||||||
proc fromData[M, N: static[int]](data: openArray[byte]; pos: var int; output: var Matrix32[M, N]) =
|
proc fromData[M, N: static[int]](data: openArray[byte]; pos: var int; output: var Matrix32[M, N]) =
|
||||||
output.data = createData(M * N)
|
if output.data == nil:
|
||||||
|
output.data = createData(M * N)
|
||||||
let bLen = output.byteSize
|
let bLen = output.byteSize
|
||||||
if readData(data, pos, output.data, bLen) != bLen:
|
if readData(data, pos, output.data, bLen) != bLen:
|
||||||
raiseDecoding()
|
raiseDecoding()
|
||||||
|
|
Loading…
Reference in New Issue