From b8732d1deeca54d1200d7dccefa04bee2b8ca3aa Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 7 Feb 2014 21:21:44 +0100 Subject: Eliminate repeating invocation of shell tools by using the pipe more efficently This reduces the number of forks and saves more than 50% of the conversion time --- src/makecolumns.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/makecolumns.sh b/src/makecolumns.sh index 6f6f9d9..b41b454 100755 --- a/src/makecolumns.sh +++ b/src/makecolumns.sh @@ -202,17 +202,12 @@ handle_new_format() { numfiles=`find . -name file_\* | wc -l` printf "done.\n" - printf "Splitting decompressed chunks into their columns (11 total) ... " - for column in `jot - 0 10 1`; do + printf "Splitting decompressed chunks into their columns (11 total) ... 0, " + for file in `jot - 0 $(( numfiles - 1 )) 11`; do printf "file_%05X " ${file}; done | xargs cat | xxd -ps -c1 > column_0 + + for column in `jot 10`; do printf "%d, " $column - for file in `jot - ${column} $(( numfiles - 1 )) 11`; do - acton=`printf file_%05X ${file}` - if [ ${column} = 0 ]; then - xxd -ps -c1 ${acton} >> column_0; - else - tr '\n\0' '\t\n' < ${acton} >> column_${column}; - fi - done; + for file in `jot - ${column} $numfiles 11`; do printf "file_%05X " ${file}; done | xargs cat | tr '\n\0' '\t\n' > column_${column} done printf "done.\n" -- cgit v1.2.3