diff options
| author | Pierre-Marie Pédrot | 2013-11-23 18:58:02 +0100 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2013-11-24 00:04:10 +0100 |
| commit | a000b714412e4b1f48bf3ffe1479cf6589874b47 (patch) | |
| tree | 5c15ee942d26ff785fc993ac3192170406d1ea02 /lib | |
| parent | c022a4a8faa9c8c7deb28744c779847d621d2b0c (diff) | |
Tweaking arity & allocation of some basic functions.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/cList.ml | 13 | ||||
| -rw-r--r-- | lib/hashcons.ml | 4 | ||||
| -rw-r--r-- | lib/hashset.ml | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/cList.ml b/lib/cList.ml index 02e46092c3..1a1993cd6f 100644 --- a/lib/cList.ml +++ b/lib/cList.ml @@ -417,14 +417,13 @@ let rec smartfilter f l = match l with else h :: tl' else tl' -let index f x = - let rec index_x n = function - | y::l -> if f x y then n else index_x (succ n) l - | [] -> raise Not_found - in - index_x 1 +let rec index_f f x l n = match l with +| [] -> raise Not_found +| y :: l -> if f x y then n else index_f f x l (succ n) + +let index f x l = index_f f x l 1 -let index0 f x l = index f x l - 1 +let index0 f x l = index_f f x l 0 let fold_left_until f accu s = let rec aux accu = function diff --git a/lib/hashcons.ml b/lib/hashcons.ml index 3a8a86e3ee..72381ae2bd 100644 --- a/lib/hashcons.ml +++ b/lib/hashcons.ml @@ -79,7 +79,9 @@ module Make (X : HashconsedType) = * sub-hcons functions. *) (* For non-recursive types it is quite easy. *) -let simple_hcons h u = h () u +let simple_hcons h u = + let h = h () in + fun x -> h u x (* For a recursive type T, we write the module of sig Comp with u equals * to (T -> T) * u0 diff --git a/lib/hashset.ml b/lib/hashset.ml index 279beb1c99..8c40e55001 100644 --- a/lib/hashset.ml +++ b/lib/hashset.ml @@ -73,7 +73,9 @@ module Make (E : EqType) = | true -> f b t.hashes.(j) i; iter_bucket (i+1) j b | false -> iter_bucket (i+1) j b in - Array.iteri (iter_bucket 0) t.table + for i = 0 to pred (Array.length t.table) do + iter_bucket 0 i (Array.unsafe_get t.table i) + done let rec count_bucket i b accu = if i >= Weak.length b then accu else |
