Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-10-30 13:19:52 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-10-30 13:57:51 +0400
commit554ed49c155633adb5782979bb7eb2cae6c64b4e (patch)
treeb6e56806d6e40f12c06a0611bed654ec02c080da /sh
parentb7e61837e7269a8eafca280f904ab4a4e1425840 (diff)
jshn: reduce the number of appends to the cleanup list to speed up processing of large json files
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'sh')
-rw-r--r--sh/jshn.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/sh/jshn.sh b/sh/jshn.sh
index a3f6d11..efac0af 100644
--- a/sh/jshn.sh
+++ b/sh/jshn.sh
@@ -37,7 +37,6 @@ _json_export() {
local __val="$2"
export -- "$__var=$__val"
- _jshn_append "JSON_UNSET" "$__var"
}
_json_add_key() {
@@ -96,6 +95,7 @@ _json_add_generic() {
_json_export "${cur}_$var" "$val"
_json_export "TYPE_${cur}_$var" "$type"
+ _jshn_append "JSON_UNSET" "${cur}_$var"
_json_add_key "$cur" "$var"
}
@@ -114,6 +114,7 @@ _json_add_table() {
_json_export "KEYS_$table" ""
[ "$itype" = "ARRAY" ] && _json_export "SEQ_$table" ""
_json_stack_push "$table"
+ _jshn_append "JSON_UNSET" "$table"
_json_get_var new_cur JSON_CUR
_json_add_generic "$type" "$1" "$new_cur" "$cur"
@@ -141,15 +142,21 @@ json_cleanup() {
local unset
_json_get_var unset JSON_UNSET
- [ -n "$unset" ] && eval "unset $unset"
+ for tmp in $unset JSON_VAR; do
+ unset \
+ ${JSON_PREFIX}UP_$tmp \
+ ${JSON_PREFIX}KEYS_$tmp \
+ ${JSON_PREFIX}SEQ_$tmp \
+ ${JSON_PREFIX}TYPE_$tmp \
+ ${JSON_PREFIX}NAME_$tmp \
+ ${JSON_PREFIX}$tmp
+ done
unset \
${JSON_PREFIX}JSON_SEQ \
${JSON_PREFIX}JSON_STACK \
${JSON_PREFIX}JSON_CUR \
- ${JSON_PREFIX}JSON_UNSET \
- ${JSON_PREFIX}KEYS_JSON_VAR \
- ${JSON_PREFIX}TYPE_JSON_VAR
+ ${JSON_PREFIX}JSON_UNSET
}
json_init() {