Commit e8192a4f authored by POTTIER Francois's avatar POTTIER Francois

A minor optimisation: removed [source] from the key in [M2].

parent 04acb802
......@@ -115,7 +115,7 @@ module Trie = struct
empty
let compare (Trie (stamp1, _, _)) (Trie (stamp2, _, _)) =
Pervasives.compare stamp1 stamp2
Pervasives.compare (stamp1 : int) stamp2
end
......@@ -219,7 +219,12 @@ module T : sig
end = struct
(* We use a map of [target, z] to a map of [source, future, a] to facts. *)
(* We use a map of [target, z] to a map of [future, a] to facts. *)
(* A minor and subtle optimization: we need not use [source] as part
of the key in [M2], because [future] determines [source]. Indeed,
[future] is (a sub-trie of) the trie generated by [init source],
and every trie contains unique stamps. *)
module M1 =
MyMap(struct
......@@ -232,10 +237,8 @@ end = struct
module M2 =
MyMap(struct
type t = Lr1.node * Trie.trie * Terminal.t
let compare (source1, future1, a1) (source2, future2, a2) =
let c = Lr1.Node.compare source1 source2 in
if c <> 0 then c else
type t = Trie.trie * Terminal.t
let compare (future1, a1) (future2, a2) =
let c = Trie.compare future1 future2 in
if c <> 0 then c else
Terminal.compare a1 a2
......@@ -249,7 +252,7 @@ end = struct
let a = first fact.word z in
update_ref m (fun m1 ->
M1.update M2.empty id (fact.target, z) m1 (fun m2 ->
M2.update None some (fact.source, fact.future, a) m2 (function
M2.update None some (fact.future, a) m2 (function
| None ->
fact
| Some earlier_fact ->
......
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