From e91ae611b66720554a711e45077ac17f15e120a4 Mon Sep 17 00:00:00 2001 From: Andy Chu Date: Thu, 12 Dec 2019 13:30:05 -0800 Subject: [PATCH] [performance] Sharp sed hack to make Token 16 bytes instead of 24. $ _bin/osh_parse.opt -n benchmarks/testdata/configure-coreutils BEFORE: dumb_alloc: gNumNew = 3492038 gNumDelete = 189920 gMemPos = 77177720 AFTER: dumb_alloc: gNumNew = 3492038 gNumDelete = 189920 gMemPos = 74281392 --- build/dev.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build/dev.sh b/build/dev.sh index aa0b999519..5f63d7e42e 100755 --- a/build/dev.sh +++ b/build/dev.sh @@ -135,8 +135,19 @@ oil-asdl-to-cpp() { # Instead of id__Eol_Tok, use Id::Eol_Tok. # case lex_mode_e::Expr - gen-asdl-cpp frontend/syntax.asdl gen-asdl-cpp osh/runtime.asdl + + gen-asdl-cpp frontend/syntax.asdl + + # CRAZY SHARP HACK to make Token 16 bytes instead of 24! (And speck is 8 + # bytes rather than 12, although we might want to get rid of it.) + # Because of C's weak type system (typedef int Id_t), this is better than + # changing ASDL. + local orig=_build/cpp/syntax_asdl.h + local tmp=_devbuild/tmp/syntax_asdl.h + sed 's/Id_t id;/uint16_t id;/g' $orig > $tmp + diff -u $orig $tmp || true + mv -v $tmp $orig } oil-cpp() {