Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"cSpell.words": [
"alphanum",
"astring",
"bitv",
"chdir",
"cmdlang",
"cmdliner",
"ENOENT",
"fpath",
"fsegment",
"functors",
"gcas",
"gitk",
"intf",
"janestreet",
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.21 (2025-08-27)

### Changed

- Replace naive bit_vector module by bitv (#96, @mbarbin).

## 0.0.20 (2025-08-14)

### Changed
Expand Down
6 changes: 6 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
(>= 4.14))
(astring
(>= 0.8.5))
(bitv
(>= 2.1))
(fpath
(>= 0.7.3))
(fpath-sexp0
Expand Down Expand Up @@ -318,6 +320,8 @@
(and
:with-dev-setup
(>= 2.8.3)))
(bitv
(>= 2.1))
(cmdlang
(>= 0.0.9))
conf-git
Expand Down Expand Up @@ -425,6 +429,8 @@
(and
:with-dev-setup
(>= 2.8.3)))
(bitv
(>= 2.1))
(cmdlang
(>= 0.0.9))
conf-git
Expand Down
45 changes: 0 additions & 45 deletions lib/volgo/src/bit_vector.ml

This file was deleted.

39 changes: 0 additions & 39 deletions lib/volgo/src/bit_vector.mli

This file was deleted.

1 change: 1 addition & 0 deletions lib/volgo/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Sexplib0.Sexp_conv)
(libraries
astring
bitv
fpath
fpath-sexp0
pp
Expand Down
32 changes: 16 additions & 16 deletions lib/volgo/src/graph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ let iter_ancestors t ~visited node ~f =
| [] -> ()
| node :: to_visit ->
let to_visit =
if Bit_vector.get visited node
if Bitv.get visited node
then to_visit
else (
Bit_vector.set visited node true;
Bitv.set visited node true;
f node;
prepend_parents t ~node ~prepend_to:to_visit)
in
Expand All @@ -259,22 +259,22 @@ let greatest_common_ancestors t ~nodes =
| node1 :: nodes ->
let node_count = Array.length t.nodes in
let common_ancestors =
let node1_ancestors = Bit_vector.create ~len:node_count false in
let node1_ancestors = Bitv.create node_count false in
iter_ancestors t ~visited:node1_ancestors node1 ~f:(fun _ -> ());
node1_ancestors
in
let visited = Bit_vector.create ~len:node_count false in
let visited = Bitv.create node_count false in
List.iter nodes ~f:(fun node ->
iter_ancestors t ~visited node ~f:(fun _ -> ());
Bit_vector.bw_and_in_place ~mutates:common_ancestors visited;
Bit_vector.reset visited false);
Bitv.bw_and_in_place ~dst:common_ancestors common_ancestors visited;
Bitv.fill visited 0 (Bitv.length visited) false);
let gcas = ref [] in
for i = node_count - 1 downto 0 do
if Bit_vector.get common_ancestors i
if Bitv.get common_ancestors i
then (
gcas := i :: !gcas;
iter_ancestors t ~visited i ~f:(fun j ->
if j <> i then Bit_vector.set common_ancestors j false))
if j <> i then Bitv.set common_ancestors j false))
done;
!gcas
;;
Expand Down Expand Up @@ -403,7 +403,7 @@ let roots t =
(* Pre condition: ancestor < descendant. *)
let is_strict_ancestor_internal t ~ancestor ~descendant =
assert (ancestor < descendant);
let visited = Bit_vector.create ~len:(descendant - ancestor + 1) false in
let visited = Bitv.create (descendant - ancestor + 1) false in
let rec loop to_visit =
match to_visit with
| [] -> false
Expand All @@ -414,10 +414,10 @@ let is_strict_ancestor_internal t ~ancestor ~descendant =
| Less ->
let to_visit =
let visited_index = node - ancestor in
if Bit_vector.get visited visited_index
if Bitv.get visited visited_index
then to_visit
else (
Bit_vector.set visited visited_index true;
Bitv.set visited visited_index true;
prepend_parents t ~node ~prepend_to:to_visit)
in
loop to_visit)
Expand Down Expand Up @@ -476,16 +476,16 @@ let descendance t a b : Descendance.t =
;;

let leaves t =
let has_children = Bit_vector.create ~len:(node_count t) false in
let has_children = Bitv.create (node_count t) false in
Array.iter t.nodes ~f:(fun node ->
match (node : Node_kind.t) with
| Root _ -> ()
| Commit { parent; _ } -> Bit_vector.set has_children parent true
| Commit { parent; _ } -> Bitv.set has_children parent true
| Merge { parent1; parent2; _ } ->
Bit_vector.set has_children parent1 true;
Bit_vector.set has_children parent2 true);
Bitv.set has_children parent1 true;
Bitv.set has_children parent2 true);
Array.filter_mapi t.nodes ~f:(fun i _ ->
if Bit_vector.get has_children i then None else Some i)
if Bitv.get has_children i then None else Some i)
|> Array.to_list
;;

Expand Down
1 change: 0 additions & 1 deletion lib/volgo/src/vcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ module User_name = User_name
include Vcs0

module Private = struct
module Bit_vector = Bit_vector
module Import = Import
module Int_table = Int_table
module Process_output = Process_output
Expand Down
3 changes: 1 addition & 2 deletions lib/volgo/src/vcs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ val git

module Hg = Hg

(** Simiar to {!val:git}, helpers are provided by the module {!module:Hg} to
(** Similar to {!val:git}, helpers are provided by the module {!module:Hg} to
build the [f] parameter.

The expectation is that you should be using the [Hg] module of the API you
Expand Down Expand Up @@ -380,7 +380,6 @@ module Private : sig
of [Vcs]. This is used e.g. by tests or libraries with strong ties to
[Vcs]. Do not use. *)

module Bit_vector = Bit_vector
module Import = Import
module Int_table = Int_table
module Process_output = Process_output
Expand Down
1 change: 1 addition & 0 deletions lib/volgo/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Volgo)
(libraries
base
bitv
eio
eio_main
expect_test_helpers_core.expect_test_helpers_base
Expand Down
44 changes: 24 additions & 20 deletions lib/volgo/test/test__bit_vector.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,38 @@
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
(*******************************************************************************)

module Bit_vector = Vcs.Private.Bit_vector
module Bitv = struct
include Bitv

let%expect_test "bw_and_inplace" =
let v0 = Bit_vector.create ~len:10 true in
print_s [%sexp (v0 : Bit_vector.t)];
let sexp_of_t t = Sexp.Atom (Bitv.L.to_string t)
end

let%expect_test "bw_and_in_place" =
let v0 = Bitv.create 10 true in
print_s [%sexp (v0 : Bitv.t)];
[%expect {| 1111111111 |}];
let v1 = Bit_vector.create ~len:10 false in
print_s [%sexp (v1 : Bit_vector.t)];
let v1 = Bitv.create 10 false in
print_s [%sexp (v1 : Bitv.t)];
[%expect {| 0000000000 |}];
for i = 0 to Bit_vector.length v1 - 1 do
if i % 2 = 0 then Bit_vector.set v1 i true
for i = 0 to Bitv.length v1 - 1 do
if i % 2 = 0 then Bitv.set v1 i true
done;
Bit_vector.bw_and_in_place ~mutates:v0 v1;
print_s [%sexp (v0 : Bit_vector.t)];
Bitv.bw_and_in_place ~dst:v0 v0 v1;
print_s [%sexp (v0 : Bitv.t)];
[%expect {| 1010101010 |}];
print_s [%sexp (v1 : Bit_vector.t)];
print_s [%sexp (v1 : Bitv.t)];
[%expect {| 1010101010 |}];
Bit_vector.reset v1 false;
for i = 0 to Bit_vector.length v1 - 1 do
if i % 3 = 0 then Bit_vector.set v1 i true
Bitv.fill v1 0 (Bitv.length v1) false;
for i = 0 to Bitv.length v1 - 1 do
if i % 3 = 0 then Bitv.set v1 i true
done;
Bit_vector.bw_and_in_place ~mutates:v0 v1;
print_s [%sexp (v0 : Bit_vector.t)];
Bitv.bw_and_in_place ~dst:v0 v0 v1;
print_s [%sexp (v0 : Bitv.t)];
[%expect {| 1000001000 |}];
print_s [%sexp (v1 : Bit_vector.t)];
print_s [%sexp (v1 : Bitv.t)];
[%expect {| 1001001001 |}];
let vsmall = Bit_vector.create ~len:5 true in
require_does_raise [%here] (fun () -> Bit_vector.bw_and_in_place ~mutates:v0 vsmall);
[%expect {| (Invalid_argument Bit_vector.bw_and_in_place) |}];
let v_small = Bitv.create 5 true in
require_does_raise [%here] (fun () -> Bitv.bw_and_in_place ~dst:v0 v0 v_small);
[%expect {| (Invalid_argument Bitv.bw_and_in_place) |}];
()
;;
1 change: 1 addition & 0 deletions volgo-dev.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ depends: [
"base" {>= "v0.17"}
"base_quickcheck" {>= "v0.17"}
"bisect_ppx" {with-dev-setup & >= "2.8.3"}
"bitv" {>= "2.1"}
"cmdlang" {>= "0.0.9"}
"conf-git"
"conf-hg"
Expand Down
1 change: 1 addition & 0 deletions volgo-tests.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ depends: [
"base" {>= "v0.17"}
"base_quickcheck" {>= "v0.17"}
"bisect_ppx" {with-dev-setup & >= "2.8.3"}
"bitv" {>= "2.1"}
"cmdlang" {>= "0.0.9"}
"conf-git"
"conf-hg"
Expand Down
1 change: 1 addition & 0 deletions volgo.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ depends: [
"dune" {>= "3.17"}
"ocaml" {>= "4.14"}
"astring" {>= "0.8.5"}
"bitv" {>= "2.1"}
"fpath" {>= "0.7.3"}
"fpath-sexp0" {>= "0.3.1"}
"pp" {>= "2.0.0"}
Expand Down
Loading