From 67c7a925c1de5ecf0981239dea1bca3ee114de26 Mon Sep 17 00:00:00 2001 From: ReneSac Date: Thu, 16 Jun 2016 18:08:15 -0300 Subject: [PATCH] Remove high() and low() procs from queues module Just in case as they are said not overloadable. No deprecation because this is during a PR: those procs didn't exist before. Also update comment due to failed optimization attempt using copyMem() for POD datatypes. --- lib/pure/collections/queues.nim | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/pure/collections/queues.nim b/lib/pure/collections/queues.nim index 5ec1d05bf6..9118165186 100644 --- a/lib/pure/collections/queues.nim +++ b/lib/pure/collections/queues.nim @@ -63,15 +63,6 @@ proc len*[T](q: Queue[T]): int {.inline.}= ## Return the number of elements of `q`. result = q.count -proc low*[T](q: Queue[T]): int {.inline.}= - ## Return the index of the oldest element of `q` (always 0). - result = 0 - -proc high*[T](q: Queue[T]): int {.inline.}= - ## Return the index of the last element inserted on `q` (equivalent to - ## `q.len - 1`). - result = q.count - 1 - template emptyCheck(q) = # Bounds check for the regular queue access. when compileOption("boundChecks"): @@ -151,8 +142,8 @@ proc add*[T](q: var Queue[T], item: T) = var cap = q.mask+1 if unlikely(q.count >= cap): var n = newSeq[T](cap*2) - for i, x in q: - shallowCopy(n[i], x) # does not use copyMem because the GC. + for i, x in q: # don't use copyMem because the GC and because it's slower. + shallowCopy(n[i], x) shallowCopy(q.data, n) q.mask = cap*2 - 1 q.wr = q.count @@ -203,8 +194,6 @@ when isMainModule: assert q[^1] == q.back and q.back == 789 q[0] = 42 q[^1] = 7 - assert q[q.low] == 42 - assert q[q.high] == 7 assert 6 in q and 789 notin q assert q.find(6) >= 0