From bdd2c807e52e90b340a8b09c41e7353c52080b46 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 14 May 2024 18:18:42 -0500 Subject: Change ridiculously slow file read implementation --- lib/grep.ml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/grep.ml b/lib/grep.ml index 7e5c3b9..0b3c10b 100644 --- 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 = -- cgit v1.2.3