Commit 2dd0e4fb authored by POTTIER Francois's avatar POTTIER Francois

In [E], store [nt, a, z] in just one word. (See attic/ntaz.patch.)

Strangely, this slows things down and does not always save memory (!?).
parent 79dc96b6
diff --git a/src/LRijkstra.ml b/src/LRijkstra.ml
index 0d65fbd..92701fe 100644
--- a/src/LRijkstra.ml
+++ b/src/LRijkstra.ml
@@ -408,17 +408,18 @@ module E : sig
end = struct
- (* For now, we implement a mapping of [s, nt, a, z] to [w]. *)
+ (* For now, we implement a mapping of [s] to [nt, a, z] to [w]. *)
+
+ let pack nt a z : int =
+ (Nonterminal.n2i nt lsl 16) lor
+ (Terminal.t2i a lsl 8) lor
+ (Terminal.t2i z)
module M =
MySet.Make(struct
- type t = Nonterminal.t * Terminal.t * Terminal.t * W.word
- let compare (nt1, a1, z1, _w1) (nt2, a2, z2, _w2) =
- let c = Nonterminal.compare nt1 nt2 in
- if c <> 0 then c else
- let c = Terminal.compare a1 a2 in
- if c <> 0 then c else
- Terminal.compare z1 z2
+ type t = int * W.word
+ let compare (ntaz1, _w1) (ntaz2, _w2) =
+ Pervasives.compare (ntaz1 : int) ntaz2
end)
let table =
@@ -430,7 +431,7 @@ end = struct
let i = Lr1.number s in
let m = table.(i) in
let a = W.first w z in
- let m' = M.add (nt, a, z, w) m in
+ let m' = M.add (pack nt a z, w) m in
m != m' && begin
incr count;
table.(i) <- m';
@@ -441,8 +442,8 @@ end = struct
let i = Lr1.number s in
let m = table.(i) in
let dummy = W.epsilon in
- match M.find (nt, a, z, dummy) m with
- | (_, _, _, w) -> f w
+ match M.find (pack nt a z, dummy) m with
+ | (_, w) -> f w
| exception Not_found -> ()
let verbose () =
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment