-
Notifications
You must be signed in to change notification settings - Fork 140
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
micro-optimization: input vector for poly::get_variables() #571
base: master
Are you sure you want to change the base?
Conversation
Pass the input vector by reference rather than by value.
Reserving capacity for the input vector with a fixed size to be passed to get_variables() prevents unnecessary reallocations during push_back operations.
I've reserved capacity for vectors passed to vector<WORD *> e;
e.push_back(a);
e.push_back(b);
poly::get_variables(BHEAD e, false, false); calls If we can use C++11, then this could be rewritten with template <typename Container>
static void get_variables (PHEAD const Container &, bool, bool); (Optionally, |
Could you measure any improvement from these in poly benches? #297 could go in with this also in principle? |
The improvement in speed is negligible. So, practically, the difference is only in writing code in a more proper style.
vs.
|
poly::get_variables()
does not need a temporary copy of the input vector containing pointers to function arguments. Passing it by reference rather than by value avoids a heap allocation and a memory copy.