Last active
July 11, 2016 09:10
-
-
Save struktured/25c58f35baf0317538a37b681a8bbfcf to your computer and use it in GitHub Desktop.
quick view of a ring buffer as an unordered array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Expose the entire array as fast as possible. Copying is avoided when the array is saturated. | |
If non empty, also return the position of the first element. *) | |
let to_array_fast b = length b |> function | |
| 0 -> A.empty, None | |
| len when A.length b.buf = len -> b.buf, Some b.start | |
| _ -> to_array b, Some 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment