Merge pull request #168 from dolmen/optimize/sr,sl,sb

Optimize _lp_sr, _lp_sl, _lp_sb
This commit is contained in:
nojhan 2013-05-05 11:50:53 -07:00
commit 0c580401bf

View File

@ -711,7 +711,7 @@ _lp_git_branch_color()
local branch
branch=$(_lp_git_branch)
if [[ ! -z "$branch" ]] ; then
if [[ -n "$branch" ]] ; then
local GD
git diff --quiet >/dev/null 2>&1
@ -803,7 +803,7 @@ _lp_hg_branch_color()
local branch
local ret
branch=$(_lp_hg_branch)
if [[ ! -z "$branch" ]] ; then
if [[ -n "$branch" ]] ; then
local has_untracked
has_untracked=$(hg status 2>/dev/null | grep '\(^\?\)' | wc -l)
@ -921,7 +921,7 @@ _lp_fossil_branch_color()
local branch
branch=$(_lp_fossil_branch)
if [[ ! -z "$branch" ]] ; then
if [[ -n "$branch" ]] ; then
local C2E # Modified files (added or edited)
local C2D # Deleted files
local C2A # Extras files
@ -1000,7 +1000,7 @@ _lp_bzr_branch_color()
local revno=${tuple[1]}
local clean=${tuple[2]}
if [[ ! -z "$branch" ]] ; then
if [[ -n "$branch" ]] ; then
if [[ "$clean" -eq 0 ]] ; then
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_COMMITS}$revno${NO_COL})"
else
@ -1325,26 +1325,19 @@ _lp_smart_mark()
# insert a space on the right
_lp_sr()
{
if [[ ! -z "$1" ]] ; then
echo -n "$1 "
fi
[[ -n "$1" ]] && echo -n "$1 "
}
# insert a space on the left
_lp_sl()
{
if [[ ! -z "$1" ]] ; then
echo -n " $1"
fi
[[ -n "$1" ]] && echo -n " $1"
}
# insert two space, before and after
_lp_sb()
{
if [[ ! -z "$1" ]] ; then
echo -n " $1 "
fi
[[ -n "$1" ]] && echo -n " $1 "
}
###################