Commits

Karsten Schmidt committed 2de51b7

optimising fill-buffer* macro

  • Participants
  • Parent commits 167f02f
  • Branches develop

Comments (0)

Files changed (1)

File src/simplecl/core.clj

   `(defmethod ^{:tag CLBuffer :private true} fill-buffer ~type
      [^CLBuffer b# f#]
      (let [^{:tag ~type} nb# (.getBuffer b#)]
-       (loop [pos# (.position nb#)]
-         (when (pos? (.remaining nb#))
+       (loop [pos# (.position nb#) remaining# (.remaining nb#)]
+         (when (pos? remaining#)
            (.put nb# (~cast (f# pos#)))
-           (recur (inc pos#))))
+           (recur (inc pos#) (dec remaining#))))
        (.rewind nb#))
      b#))