From 203b7649a2ef569f8de9cd70163f614d1001ba04 Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Wed, 8 Jul 2015 18:52:51 +0200 Subject: [PATCH] perf: reduce calls to git log --- bin/git-effort | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 32cdf54..c678fe8 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -36,10 +36,7 @@ show_cursor_and_cleanup() { # active_days() { - date $1 | uniq | awk ' - { sum += 1 } - END { print sum } - ' + uniq <(echo "$1") | wc -l } # @@ -63,7 +60,8 @@ color_for() { effort() { file=$1 - commits=`git log --oneline "$file" | wc -l` + local commit_dates=`date $file` + commits=`echo "$commit_dates" | wc -l` color='90' # ignore <= --above @@ -82,7 +80,7 @@ effort() { msg=$(printf " \033[${color}m%s %-10d" $f_dot $commits) # active days - active=`active_days "$file"` + active=`active_days "$commit_dates"` color_for $active msg="$msg $(printf "\033[${color}m %d\033[0m\n" $active)" echo "$msg"