Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: use "const ref" for function arguments #34

Open
alastairreid opened this issue Feb 10, 2025 · 0 comments
Open

Optimization: use "const ref" for function arguments #34

alastairreid opened this issue Feb 10, 2025 · 0 comments

Comments

@alastairreid
Copy link

When generating C++ code, using const ref is faster for arrays, records and large ints/bitvectors. (But it is probably slower for values that already fit in registers.)

Note that applying the same optimization for C code is, in principle, easy: "just add a star in front of the variable's name" but rapidly becomes tedious and error prone as we have to insert "&" in front of function arguments, convert function arguments to l-values, (optionally?) optimize "&*" when a function argument is passed further down the call graph and do the right thing in the foreign function interface.
So we will probably not try to optimize generated C code in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant