jshn: refactor _jshn_append to require fewer evals
authorFelix Fietkau <nbd@openwrt.org>
Wed, 30 Oct 2013 10:50:39 +0000 (11:50 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 30 Oct 2013 10:50:39 +0000 (11:50 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
sh/jshn.sh

index a324c54e7a46fb8f4b324408fb09f15e7d55d9c4..9e7f4449d08a579a4a3b3c4e376a45a5bcb3769e 100644 (file)
@@ -22,12 +22,9 @@ __jshn_raw_append() {
 
 _jshn_append() {
        # var=$1
-       # value=$2
-       # sep=$3
-       local __old_val
-
-       _json_get_var __old_val "$1"
-       _json_set_var "$1" "${__old_val:+$__old_val${3:- }}$2"
+       local _a_value="$2"
+       local _a_sep="${3:- }"
+       eval "${JSON_PREFIX}$1=\"\${${JSON_PREFIX}$1:+\${${JSON_PREFIX}$1}\${_a_value:+\$_a_sep}}\$_a_value\""
 }
 
 _json_export() {