Turn some inline procs into templates
As much as I believe in the power of optimizing compilers, it turned out that the use of forced inlining with templates still creates a significant difference in the release builds of nim-faststreams.
This commit is contained in:
parent
700f21b54f
commit
061543d039
|
@ -1,12 +1,12 @@
|
|||
proc baseAddr*[T](x: openarray[T]): pointer = cast[pointer](x)
|
||||
|
||||
proc shift*(p: pointer, delta: int): pointer {.inline.} =
|
||||
template shift*(p: pointer, delta: int): pointer =
|
||||
cast[pointer](cast[int](p) + delta)
|
||||
|
||||
proc distance*(a, b: pointer): int {.inline.} =
|
||||
template distance*(a, b: pointer): int =
|
||||
cast[int](b) - cast[int](a)
|
||||
|
||||
proc shift*[T](p: ptr T, delta: int): ptr T {.inline.} =
|
||||
template shift*[T](p: ptr T, delta: int): ptr T =
|
||||
cast[ptr T](shift(cast[pointer](p), delta * sizeof(T)))
|
||||
|
||||
when (NimMajor,NimMinor,NimPatch) >= (0,19,9):
|
||||
|
|
Loading…
Reference in New Issue