Skip to content

Commit

Permalink
chore: only allocate error message on error
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

ps-id: 68dde42e-21ac-42f3-8041-5d06e0cd8256
  • Loading branch information
rgrinberg committed Aug 27, 2022
1 parent 7ce9e8e commit 806f39b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/dune_engine/rule_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ module Shared = struct
| None -> (
let missing, errors =
let process_target target (missing, errors) =
let expected_syscall_path = Path.to_string (Path.build target) in
match compute_digest target with
| Ok (_ : Digest.t) -> (missing, errors)
| No_such_file -> (target :: missing, errors)
Expand All @@ -401,13 +400,17 @@ module Shared = struct
(missing, (target, Unix_error.Detailed.pp unix_error) :: errors)
| Error exn ->
let error =
match exn with
| Sys_error msg ->
Pp.verbatim
(String.drop_prefix_if_exists
~prefix:(expected_syscall_path ^ ": ")
msg)
| exn -> Pp.verbatim (Printexc.to_string exn)
Pp.verbatim
(match exn with
| Sys_error msg ->
let prefix =
let expected_syscall_path =
Path.to_string (Path.build target)
in
expected_syscall_path ^ ": "
in
String.drop_prefix_if_exists ~prefix msg
| exn -> Printexc.to_string exn)
in
(missing, (target, error) :: errors)
in
Expand Down

0 comments on commit 806f39b

Please sign in to comment.