From b37fdc634c8cd7d15e61fdd1336a883f046e0e66 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Sat, 28 Dec 2024 23:02:51 +0300 Subject: [PATCH] only do date calc once for perf --- blag | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/blag b/blag index 4f18101..c922afe 100755 --- a/blag +++ b/blag @@ -90,11 +90,14 @@ render() {( path=$1 shift - birth=$(stat -c'%W' "$path") - if (( birth > 0 )); then - CREATED_AT=$(date --rfc-3339=seconds -d "@$birth") + if (( ! DATES_CALCULATED )); then + birth=$(stat -c'%W' "$path") + if (( birth > 0 )); then + CREATED_AT=$(date --rfc-3339=seconds -d "@$birth") + fi + MODIFIED_AT=$(date --rfc-3339=seconds -d "@$(stat -c '%Y' "$path")") + DATES_CALCULATED=1 fi - MODIFIED_AT=$(date --rfc-3339=seconds -d "@$(stat -c '%Y' "$path")") #shellcheck disable=SC1090 . "$path" "$@"