diff options
| author | Arnaud Spiwack | 2014-02-24 16:47:59 +0100 |
|---|---|---|
| committer | Arnaud Spiwack | 2014-02-24 16:47:59 +0100 |
| commit | 23eeacf4c22055a60b9f64ba308f9198ba4d938b (patch) | |
| tree | f2e08461fbc2eba6eea27b757d8cde1ab7b68263 /lib/iStream.ml | |
| parent | 1bb2ee934bc2082865ee64f539497f3bc292a439 (diff) | |
IStream: change type of thunk, spare allocations.
Two changes:
- 'a Lazy.t becomes unit -> 'a
- 'a t becomes 'a u (the view type)
This spares two Lazy.force, and leverages Lazy.lazy_from_fun. Considering Lazy.force is fairly slow, in particular because of the write-barrier, this should be beneficial.
Diffstat (limited to 'lib/iStream.ml')
| -rw-r--r-- | lib/iStream.ml | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/iStream.ml b/lib/iStream.ml index 65a336dafd..1d9f55998e 100644 --- a/lib/iStream.ml +++ b/lib/iStream.ml @@ -6,11 +6,11 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -type ('a,'r) peek = +type ('a,'r) u = | Nil | Cons of 'a * 'r -type 'a node = ('a,'a t) peek +type 'a node = ('a,'a t) u and 'a t = 'a node Lazy.t @@ -18,7 +18,7 @@ let empty = Lazy.lazy_from_val Nil let cons x s = Lazy.lazy_from_val (Cons (x, s)) -let thunk s = lazy (Lazy.force (Lazy.force s)) +let thunk = Lazy.lazy_from_fun let rec force s = match Lazy.force s with | Nil -> () |
