-
Notifications
You must be signed in to change notification settings - Fork 40
Change DmpAlg to use preallocated arrays #283
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
base: master
Are you sure you want to change the base?
Conversation
dcalc/DmpCeff.cc
Outdated
p_ = new double[nr_order_]; | ||
fjac_ = new double*[nr_order_]; | ||
// How do you want to check this? | ||
assert(nr_order_ <= max_nr_order_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how OpenSTA usually checks things like this. Let me know and I'll update it to the preferred method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never with assert (tag search or grep for assert and you will see that yourself). You can answer your own question by reading the other code in the same file. As an exercise I want you to explain why the check is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I've changed the function to throw a DmpError
if the order is greater than max_nr_order_
. I've taken another look at the code, and I'm still having trouble seeing what makes the check unnecessary.
If you want a project I would not stop there if I was working on this (I wrote this 25 years ago). But this PR is simple enough to use as a first step. |
DmpAlg isn't called with nr_order_ > 3 so this change saves 9 news and 9 frees for each construction and destruction of the class.
Look at the DmpAlg constructor calls |
I'm aware that DmpAlg is currently not called with any |
@jjcherry56 is the check the only thing you'd liked changed? I'd prefer to keep it, but I'll remove it if that's your only objection. |
DmpAlg isn't called with nr_order_ > 3 so this change saves 9 news and 9 frees for each construction and destruction of the class.