From: Matt Corallo Date: Sat, 25 Sep 2021 00:38:03 +0000 (+0000) Subject: Cache multi-line sed replacements across methods to improve runtime X-Git-Tag: v0.0.101.2^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9e501cbbcde7b6624ec03372452e915967e84064;p=ldk-c-bindings Cache multi-line sed replacements across methods to improve runtime --- diff --git a/genbindings.sh b/genbindings.sh index e6ffd8b..f74b2ac 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -230,9 +230,12 @@ while read LINE; do # We'll print this at the end ;; "XXX"*) - STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + NEW_STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + if [ "$NEW_STRUCT_NAME" != "$STRUCT_NAME" ]; then + STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$NEW_STRUCT_NAME/{:s" -e "/\} LDK$NEW_STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" + fi + STRUCT_NAME="$NEW_STRUCT_NAME" METHOD_NAME="$(echo "$LINE" | awk '{ print $3 }')" - STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$STRUCT_NAME/{:s" -e "/\} LDK$STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" METHOD="$(echo "$STRUCT_CONTENTS" | grep "(\*$METHOD_NAME)")" if [ "$METHOD" = "" ]; then echo "Unable to find method declaration for $LINE"