only do date calc once for perf

This commit is contained in:
slonkazoid 2024-12-28 23:02:51 +03:00
parent f027208f58
commit b37fdc634c
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM

11
blag
View file

@ -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" "$@"