Skip to content

Commit

Permalink
more bs ->u
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Jul 22, 2023
1 parent 6fbac76 commit 861b40c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
26 changes: 13 additions & 13 deletions jscomp/others/belt_HashMap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let rec copyBucketReHash ~hash ~h_buckets ~ndata_tail old_bucket =
match C.toOpt old_bucket with
| None -> ()
| Some cell ->
let nidx = (hash cell.N.key [@bs]) land (A.length h_buckets - 1) in
let nidx = (hash cell.N.key [@u]) land (A.length h_buckets - 1) in
let v = C.return cell in
(match C.toOpt (A.getUnsafe ndata_tail nidx) with
| None -> A.setUnsafe h_buckets nidx v
Expand Down Expand Up @@ -70,7 +70,7 @@ let resize ~hash h =
done)

let rec replaceInBucket ~eq key info cell =
if eq cell.N.key key [@bs] then (
if eq cell.N.key key [@u] then (
cell.N.value <- info;
false)
else
Expand All @@ -81,7 +81,7 @@ let rec replaceInBucket ~eq key info cell =
let set0 h key value ~eq ~hash =
let h_buckets = h.C.buckets in
let buckets_len = A.length h_buckets in
let i = (hash key [@bs]) land (buckets_len - 1) in
let i = (hash key [@u]) land (buckets_len - 1) in
let l = A.getUnsafe h_buckets i in
(match C.toOpt l with
| None ->
Expand All @@ -106,22 +106,22 @@ let rec removeInBucket h h_buckets i key prec bucket ~eq =
| None -> ()
| Some cell ->
let cell_next = cell.N.next in
if eq cell.N.key key [@bs] then (
if eq cell.N.key key [@u] then (
prec.N.next <- cell_next;
h.C.size <- h.C.size - 1)
else removeInBucket ~eq h h_buckets i key cell cell_next

let remove h key =
let h_buckets = h.C.buckets in
let i =
((Belt_Id.getHashInternal h.C.hash) key [@bs]) land (A.length h_buckets - 1)
((Belt_Id.getHashInternal h.C.hash) key [@u]) land (A.length h_buckets - 1)
in
let bucket = A.getUnsafe h_buckets i in
match C.toOpt bucket with
| None -> ()
| Some cell ->
let eq = Belt_Id.getEqInternal h.C.eq in
if eq cell.N.key key [@bs] then (
if eq cell.N.key key [@u] then (
A.setUnsafe h_buckets i cell.N.next;
h.C.size <- h.C.size - 1)
else removeInBucket ~eq h h_buckets i key cell cell.N.next
Expand All @@ -130,33 +130,33 @@ let rec getAux ~eq key buckets =
match C.toOpt buckets with
| None -> None
| Some cell ->
if eq key cell.N.key [@bs] then Some cell.N.value
if eq key cell.N.key [@u] then Some cell.N.value
else getAux ~eq key cell.N.next

let get h key =
let h_buckets = h.C.buckets in
let nid =
((Belt_Id.getHashInternal h.C.hash) key [@bs]) land (A.length h_buckets - 1)
((Belt_Id.getHashInternal h.C.hash) key [@u]) land (A.length h_buckets - 1)
in
match C.toOpt (A.getUnsafe h_buckets nid) with
| None -> None
| Some (cell1 : _ N.bucket) -> (
let eq = Belt_Id.getEqInternal h.C.eq in
if eq key cell1.key [@bs] then Some cell1.value
if eq key cell1.key [@u] then Some cell1.value
else
match C.toOpt cell1.N.next with
| None -> None
| Some cell2 -> (
if eq key cell2.key [@bs] then Some cell2.value
if eq key cell2.key [@u] then Some cell2.value
else
match C.toOpt cell2.next with
| None -> None
| Some cell3 ->
if eq key cell3.key [@bs] then Some cell3.value
if eq key cell3.key [@u] then Some cell3.value
else getAux ~eq key cell3.next))

let rec memInBucket key cell ~eq =
(eq cell.N.key key [@bs])
(eq cell.N.key key [@u])
||
match C.toOpt cell.N.next with
| None -> false
Expand All @@ -165,7 +165,7 @@ let rec memInBucket key cell ~eq =
let has h key =
let h_buckets = h.C.buckets in
let nid =
((Belt_Id.getHashInternal h.C.hash) key [@bs]) land (A.length h_buckets - 1)
((Belt_Id.getHashInternal h.C.hash) key [@u]) land (A.length h_buckets - 1)
in
let bucket = A.getUnsafe h_buckets nid in
match C.toOpt bucket with
Expand Down
20 changes: 10 additions & 10 deletions jscomp/others/belt_HashSet.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,7 +17,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
Expand All @@ -38,7 +38,7 @@ let rec copyBucket ~hash ~h_buckets ~ndata_tail old_bucket =
| None -> ()
| Some cell ->
let nidx =
((Belt_Id.getHashInternal hash) cell.N.key [@bs])
((Belt_Id.getHashInternal hash) cell.N.key [@u])
land (A.length h_buckets - 1)
in
let v = C.return cell in
Expand Down Expand Up @@ -70,7 +70,7 @@ let tryDoubleResize ~hash h =

let rec removeBucket ~eq h h_buckets i key prec cell =
let cell_next = cell.N.next in
if (Belt_Id.getEqInternal eq) cell.N.key key [@bs] then (
if (Belt_Id.getEqInternal eq) cell.N.key key [@u] then (
prec.N.next <- cell_next;
h.C.size <- h.C.size - 1)
else
Expand All @@ -82,14 +82,14 @@ let remove h key =
let eq = h.C.eq in
let h_buckets = h.C.buckets in
let i =
((Belt_Id.getHashInternal h.C.hash) key [@bs]) land (A.length h_buckets - 1)
((Belt_Id.getHashInternal h.C.hash) key [@u]) land (A.length h_buckets - 1)
in
let l = A.getUnsafe h_buckets i in
match C.toOpt l with
| None -> ()
| Some cell -> (
let next_cell = cell.N.next in
if (Belt_Id.getEqInternal eq) cell.N.key key [@bs] then (
if (Belt_Id.getEqInternal eq) cell.N.key key [@u] then (
h.C.size <- h.C.size - 1;
A.setUnsafe h_buckets i next_cell)
else
Expand All @@ -98,7 +98,7 @@ let remove h key =
| Some next_cell -> removeBucket ~eq h h_buckets i key cell next_cell)

let rec addBucket h key cell ~eq =
if not ((Belt_Id.getEqInternal eq) cell.N.key key [@bs]) then
if not ((Belt_Id.getEqInternal eq) cell.N.key key [@u]) then
let n = cell.N.next in
match C.toOpt n with
| None ->
Expand All @@ -109,7 +109,7 @@ let rec addBucket h key cell ~eq =
let add0 h key ~hash ~eq =
let h_buckets = h.C.buckets in
let buckets_len = A.length h_buckets in
let i = ((Belt_Id.getHashInternal hash) key [@bs]) land (buckets_len - 1) in
let i = ((Belt_Id.getHashInternal hash) key [@u]) land (buckets_len - 1) in
let l = A.getUnsafe h_buckets i in
(match C.toOpt l with
| None ->
Expand All @@ -121,7 +121,7 @@ let add0 h key ~hash ~eq =
let add h key = add0 ~hash:h.C.hash ~eq:h.C.eq h key

let rec memInBucket ~eq key cell =
((Belt_Id.getEqInternal eq) cell.N.key key [@bs])
((Belt_Id.getEqInternal eq) cell.N.key key [@u])
||
match C.toOpt cell.N.next with
| None -> false
Expand All @@ -130,7 +130,7 @@ let rec memInBucket ~eq key cell =
let has h key =
let eq, h_buckets = (h.C.eq, h.C.buckets) in
let nid =
((Belt_Id.getHashInternal h.C.hash) key [@bs]) land (A.length h_buckets - 1)
((Belt_Id.getHashInternal h.C.hash) key [@u]) land (A.length h_buckets - 1)
in
let bucket = A.getUnsafe h_buckets nid in
match C.toOpt bucket with
Expand Down
8 changes: 4 additions & 4 deletions jscomp/others/belt_HashSet.mli
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
type t = int
module I0 =
(val Belt.Id.hashableU
~hash:(fun[\@bs] (a : t) -> a & 0xff_ff)
~eq:(fun[\@bs] a b -> a = b)
~hash:(fun[\@u] (a : t) -> a & 0xff_ff)
~eq:(fun[\@u] a b -> a = b)
)
let s0 = make ~id:(module I0) ~hintSize:40
module I1 =
(val Belt.Id.hashableU
~hash:(fun[\@bs] (a : t) -> a & 0xff)
~eq:(fun[\@bs] a b -> a = b)
~hash:(fun[\@u] (a : t) -> a & 0xff)
~eq:(fun[\@u] a b -> a = b)
)
let s1 = make ~id:(module I1) ~hintSize:40
]}
Expand Down
4 changes: 2 additions & 2 deletions jscomp/others/node_process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ external exit : int -> 'a = "exit" [@@mel.module "process"]
external cwd : unit -> string = "cwd" [@@mel.module "process"]

external uptime : t -> unit -> float = "uptime"
[@@mel.send]
[@@mel.send]
(** The process.uptime() method returns the number of seconds
the current Node.js process has been running.) *)

Expand All @@ -52,4 +52,4 @@ external uptime : t -> unit -> float = "uptime"
*)
let putEnvVar key (var : string) = Js.Dict.set process##env key var

let deleteEnvVar s = (Js.Dict.unsafeDeleteKey process##env s [@bs])
let deleteEnvVar s = (Js.Dict.unsafeDeleteKey process##env s [@u])

0 comments on commit 861b40c

Please sign in to comment.