From 061543d0399ac6878a533e3290125f9fa7df45bf Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 8 Jul 2019 21:55:00 +0300 Subject: [PATCH] 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. --- stew/ranges/ptr_arith.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stew/ranges/ptr_arith.nim b/stew/ranges/ptr_arith.nim index 96635fa..af00202 100644 --- a/stew/ranges/ptr_arith.nim +++ b/stew/ranges/ptr_arith.nim @@ -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):