diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-14 18:18:42 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-14 18:18:42 -0500 |
commit | bdd2c807e52e90b340a8b09c41e7353c52080b46 (patch) | |
tree | b438ba5bb319dd6dcfeb8bc98ba25237837559b7 /lib/grep.ml | |
parent | 0bc0958e789847d3065f4d084a96117d62d18691 (diff) | |
download | stitch-bdd2c807e52e90b340a8b09c41e7353c52080b46.tar.gz stitch-bdd2c807e52e90b340a8b09c41e7353c52080b46.tar.bz2 stitch-bdd2c807e52e90b340a8b09c41e7353c52080b46.zip |
Change ridiculously slow file read implementation
Diffstat (limited to '')
-rw-r--r-- | lib/grep.ml | 19 |
1 files 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 = |