Skip to content

Commit

Permalink
Remove nth's linear search overhead in bcf reader
Browse files Browse the repository at this point in the history
  • Loading branch information
athos committed Dec 5, 2023
1 parent 8fb577a commit 0330ac4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cljam/io/bcf/reader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@
type-id (bit-and 0x0F type-byte)]
(case type-id
0 (repeat n-sample nil)
7 (doall (repeatedly n-sample
#(bytes->strs (bb/read-bytes bb total-len))))
(->> #(read-typed-atomic-value bb type-id)
(repeatedly (* n-sample total-len))
(partition total-len)
(map (fn [xs] (take-while #(not= % :eov) xs)))
doall)))))
7 (mapv (fn [_] (bytes->strs (bb/read-bytes bb total-len)))
(range n-sample))
(into []
(comp (map (fn [_] (read-typed-atomic-value bb type-id)))
(partition-all total-len)
(map (fn [xs] (take-while #(not= % :eov) xs))))
(range (* n-sample total-len)))))))

(defn- read-typed-kv
"Reads a key-value pair."
Expand Down

0 comments on commit 0330ac4

Please sign in to comment.