Remove extra allocation in drop.

This commit is contained in:
Calvin Rose 2023-04-24 09:41:33 -05:00
parent 347721ae40
commit 440af9fd64
1 changed files with 3 additions and 4 deletions

View File

@ -1146,10 +1146,9 @@
(def use-str (bytes? ind))
(def f (if use-str string/slice tuple/slice))
(def len (length ind))
(def [start end]
(if (>= n 0)
[(min n len) len]
[0 (max 0 (+ len n))]))
(def negn (>= n 0))
(def start (if negn (min n len) 0))
(def end (if negn len (max 0 (+ len n))))
(f ind start end))
(defn drop-until