Skip to content

Commit ddb935d

Browse files
committed
Add a new memo table for canonical modules
1 parent 73dded8 commit ddb935d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/xref2/tools.ml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,16 @@ module LookupAndResolveMemo = MakeMemo (struct
346346
let hash = Hashtbl.hash
347347
end)
348348

349+
module HandleCanonicalModuleMemo = MakeMemo (struct
350+
type t = Odoc_model.Paths.Path.Module.t
351+
352+
type result = Odoc_model.Paths.Path.Module.t
353+
354+
let equal x3 y3 = x3 = y3
355+
356+
let hash y = Hashtbl.hash y
357+
end)
358+
349359
module ExpansionOfModuleMemo = MakeMemo (struct
350360
type t = Cpath.Resolved.module_
351361

@@ -1237,7 +1247,7 @@ and reresolve_module : Env.t -> Cpath.Resolved.module_ -> Cpath.Resolved.module_
12371247
| r -> `Canonical (reresolve_module env p, r))
12381248
| `OpaqueModule m -> `OpaqueModule (reresolve_module env m)
12391249

1240-
and handle_canonical_module env p2 =
1250+
and handle_canonical_module_real env p2 =
12411251
let strip_alias : Cpath.Resolved.module_ -> Cpath.Resolved.module_ =
12421252
fun x -> match x with `Alias (_, _, Some p) -> p | _ -> x
12431253
in
@@ -1304,7 +1314,10 @@ and handle_canonical_module env p2 =
13041314
if expanded then rp
13051315
else process_module_path env ~add_canonical:false m rp
13061316
in
1307-
`Resolved Lang_of.(Path.resolved_module (empty ()) cpath)
1317+
Lang_of.(Path.module_ (empty ()) (`Resolved cpath))
1318+
1319+
and handle_canonical_module env p2 =
1320+
HandleCanonicalModuleMemo.memoize handle_canonical_module_real env p2
13081321

13091322
and handle_canonical_module_type env p2 =
13101323
let cp2 = Component.Of_Lang.(module_type_path (empty ()) p2) in

0 commit comments

Comments
 (0)