Place overflow within if statement

doing unnecessary math when it might not be required. 
This will probably save 12 nanoseconds.
This commit is contained in:
Heavybullets8 2022-04-28 02:10:33 +00:00 committed by GitHub
parent e280bad4d2
commit 9e06680363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,11 +35,9 @@ do
date=$(date '+%Y_%m_%d_%H_%M_%S')
cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"'
mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r")
overflow=$(expr ${#list_backups[@]} - $number_of_backups)
if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then
overflow=$(expr ${#list_backups[@]} - $number_of_backups)
echo && mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -nr | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow")
for i in "${list_overflow[@]}"
do