From 57e3bda66a3ad1704a7ddc091c254fba8441801f Mon Sep 17 00:00:00 2001 From: Antti Kantee Date: Sat, 14 Nov 2015 18:36:17 +0000 Subject: [PATCH] rumprun-bake: _uniq each config only in its final state Hugely speeds up config processing: makes "rumprun-bake list" go from 150ms to 40ms on my machine and, most importantly, removes human-observable sluggishness. --- app-tools/rumprun-bake.in | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app-tools/rumprun-bake.in b/app-tools/rumprun-bake.in index 93f9e36..a572870 100644 --- a/app-tools/rumprun-bake.in +++ b/app-tools/rumprun-bake.in @@ -92,9 +92,10 @@ _nothaveconf () done } -# implement "sort | uniq" ourselves so that we don't completely +# Implement "sort | uniq" ourselves so that we don't completely # screw up the order of the arguments. not 100% sure it matters, but it's -# easy enough +# easy enough. Also, notably, doing it locally is ~50% faster (which +# starts to matter when you have enough configs). _uniq () { local listname newlist @@ -151,7 +152,6 @@ assimilate () _haveconf ${from} eval CONFIG_${to}=\"\${CONFIG_${to}} \${CONFIG_${from}}\" done - _uniq CONFIG_${to} } nuke () @@ -171,7 +171,6 @@ add () _haveconf ${confname} eval CONFIG_${confname}=\"\${CONFIG_${confname}} $@\" - _uniq CONFIG_${confname} } remove () @@ -246,9 +245,17 @@ _readconfig () unset CURCONF - # limit visibility of _configs + # Publish configs which are not private + # Note: technically we need to _uniq configs only when they are + # used, but this is easier and less error-prone. Consider + # just-in-time an ace up our sleeve for when config processing + # really gets too slow. for x in ${ALLCONFIGS}; do - [ "${x#_}" = "${x}" ] || _filter ${x} ALLCONFIGS + if [ "${x#_}" = "${x}" ]; then + _uniq ${x} + else + _filter ${x} ALLCONFIGS + fi done } -- 2.39.5