From b06bdab57e7289573f6e258588b1ffd927c607c2 Mon Sep 17 00:00:00 2001 From: Sam Zaydel Date: Fri, 3 Aug 2018 14:53:36 -0700 Subject: [PATCH] Cheaper and faster prehash generation mechanism --- c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/c b/c index f76d20b..7c45ce6 100755 --- a/c +++ b/c @@ -124,11 +124,20 @@ fi comp+=("$CPPFLAGS") # hash all of our data -prehash="$CC ${comp[@]}" # compiler + flags and files +prehash= +argsprehash="$CC" for f in "${comp[@]}"; do - [ -f "$f" ] && prehash+="$f $(cpp "$f" 2>&1)" + if [ -f "$f" ]; then + prehash+=$($hash_func < "$f" | cut -d' ' -f1 2>&1) + else + # Skip any empty args resulting from extra spaces + [ "$f" == "" ] && continue + argsprehash+="$f" + fi done +prehash+=$($hash_func <<< "$argsprehash" | cut -d' ' -f1 2>&1) + # hash everything into one unique identifier, for caching purposes id="c$("$hash_func" <<< "$prehash" | cut -d' ' -f1)" tmpdir="$tmproot/$id.src"