stitch

Note taking for messy minimalists

git clone git://mccd.space/stitch
commit bdd2c807e52e90b340a8b09c41e7353c52080b46
parent 0bc0958e789847d3065f4d084a96117d62d18691
Author: Marc Coquand <marc@mccd.space>
Date:   Tue, 14 May 2024 18:18:42 -0500

Change ridiculously slow file read implementation

Diffstat:
Mlib/grep.ml | 19+++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/lib/grep.ml b/lib/grep.ml
@@ -111,17 +111,16 @@ let pretty_format parsed_headlines =
 
 let get_full_content_command file = [ "cat"; file ]
 
+let read_whole_file filename =
+  (* open_in_bin works correctly on Unix and Windows *)
+  let ch = open_in_bin filename in
+  let s = really_input_string ch (in_channel_length ch) in
+  close_in ch;
+  s
+
+
 let get_full_file_content_content file =
-  let open Shexp_process in
-  let open Shexp_process.Infix in
-  ( file
-  , eval
-      (chdir
-         execution_directory
-         (find_sort_name ()
-          |- call headline_args
-          |- call (get_full_content_command file)
-          |- read_all)) )
+  file, read_whole_file (execution_directory ^ "/" ^ file)
 
 
 let parse_full_content files =