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:
Zahary Karadjov 2019-07-08 21:55:00 +03:00
parent 700f21b54f
commit 061543d039
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 3 additions and 3 deletions

View File

@ -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):