Index of opam packages, dune libraries and modules in an OCaml project
0

Configure Feed

Select the types of activity you want to include in your feed.

project-index: clear merlint findings

Add an ISC LICENSE.md (E913), link the type in the (/) doc with
{!type-t} (E420), and lift the per-directory readdir cache out of
resolve_module_files into a dir_entries helper so the function is back
under the length threshold (E005).

+32 -16
+15
LICENSE.md
··· 1 + ISC License 2 + 3 + Copyright (c) 2026 Thomas Gazagnaire <thomas@gazagnaire.org> 4 + 5 + Permission to use, copy, modify, and distribute this software for any 6 + purpose with or without fee is hereby granted, provided that the above 7 + copyright notice and this permission notice appear in all copies. 8 + 9 + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+16 -15
lib/project_index.ml
··· 783 783 source does. *) 784 784 let module_suffixes = [ ".ml"; ".mli"; ".mll"; ".mly" ] 785 785 786 + (* A per-call directory cache: [resolve_module_files]'s traversal and its 787 + per-module [has_file] check both ask for a directory's entries, the latter 788 + once per candidate module and suffix, which otherwise re-runs [readdir] (and 789 + reallocates its array) for every module in the directory. *) 790 + let dir_entries () = 791 + let cache = Hashtbl.create 16 in 792 + fun dir -> 793 + let key = Fpath.to_string dir in 794 + match Hashtbl.find_opt cache key with 795 + | Some e -> e 796 + | None -> 797 + let e = try Sys.readdir key with Sys_error _ -> [||] in 798 + Hashtbl.add cache key e; 799 + e 800 + 786 801 let resolve_module_files ~recurse ~dir ~spec = 787 - (* Read each directory once: the traversal and the per-module [has_file] 788 - existence check below both ask for a directory's entries, the latter once 789 - per candidate module and suffix, which otherwise re-runs [readdir] (and 790 - reallocates its array) for every module in the directory. *) 791 - let entries = 792 - let cache = Hashtbl.create 16 in 793 - fun dir -> 794 - let key = Fpath.to_string dir in 795 - match Hashtbl.find_opt cache key with 796 - | Some e -> e 797 - | None -> 798 - let e = try Sys.readdir key with Sys_error _ -> [||] in 799 - Hashtbl.add cache key e; 800 - e 801 - in 802 + let entries = dir_entries () in 802 803 (* A module is its containing directory paired with its base name (no 803 804 extension); keeping the pair avoids round-tripping every candidate through 804 805 [Fpath.to_string] and back through [Fpath.v]/[parent] below. *)
+1 -1
lib/project_index.mli
··· 37 37 [root]. *) 38 38 39 39 val ( / ) : t -> string -> t 40 - (** [t / seg] appends the relative segment [seg] to [t]. *) 40 + (** [t / seg] appends the relative segment [seg] to {!type-t}. *) 41 41 42 42 val to_string : t -> string 43 43 (** [to_string t] is the canonical absolute string, for keys and diagnostics.