diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-05-02T21·58+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-05-02T21·58+0000 |
commit | d300b4383dabb007db08c7165fb327c12dbe8e71 (patch) | |
tree | 30b02d509ebe41d065e8c148d80506952c8e492d /src/aterm-helper.pl | |
parent | 68174bdc7d68746c5471e87bb74909c552e98644 (diff) |
* Optimise null-ary term builders. Also declare all term builder
functions as pure, which might improve performance a bit.
Diffstat (limited to 'src/aterm-helper.pl')
-rwxr-xr-x | src/aterm-helper.pl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/aterm-helper.pl b/src/aterm-helper.pl index 1feff0ccd098..3bb466fe3bb8 100755 --- a/src/aterm-helper.pl +++ b/src/aterm-helper.pl @@ -99,8 +99,17 @@ while (<STDIN>) { print IMPL "AFun sym$funname = 0;\n"; + if ($arity == 0) { + print HEADER "extern ATerm const$funname;\n\n"; + print IMPL "ATerm const$funname = 0;\n"; + } + + print HEADER "static inline $result make$funname($formals) __attribute__ ((pure, nothrow));\n"; print HEADER "static inline $result make$funname($formals) {\n"; - if ($arity <= 6) { + if ($arity == 0) { + print HEADER " return const$funname;\n"; + } + elsif ($arity <= 6) { print HEADER " return (ATerm) ATmakeAppl$arity(sym$funname$args);\n"; } else { $args =~ s/^,//; @@ -119,6 +128,10 @@ while (<STDIN>) { $init .= " sym$funname = ATmakeAFun(\"$const\", $arity, ATfalse);\n"; $init .= " ATprotectAFun(sym$funname);\n"; + if ($arity == 0) { + $init .= " const$funname = (ATerm) ATmakeAppl0(sym$funname);\n"; + $init .= " ATprotect(&const$funname);\n"; + } } elsif (/^\s*(\w+)\s*=\s*(.*)$/) { |