-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Reserve space for LocalVector if size is known #100251
base: master
Are you sure you want to change the base?
Conversation
This is not a codestyle change, just to be clear, this is performance improvements theoretically |
IMO this should be considered a codestyle improvement before being regarded as a performance optimization. It's a best practice stuff. Not every Should probably mention this in code standard, remind everyone to do this. |
We call things that are mostly or only style changes codestyle, otherwise it's very misleading as "this is only surface level" |
core/math/quick_hull.cpp
Outdated
@@ -340,6 +340,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ | |||
Geometry3D::MeshData::Face f; | |||
f.plane = E.plane; | |||
|
|||
f.indices.reserve(3); |
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.
This whole f
variable should be removed, as it is only used for the pushback, which will make a copy anyway.
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.
Should be addressed in another PR, will try impl this ASAP.
If this was a codestyle change instead of an optimization, it would be a bad one because it increases the complexity of the code :)
I agree it's good practice to call |
As stated in 99936(comment), use
LocalVector::reserve()
if we can.This covers the
core
directory. All these cases are trival and should be riskless.Some length are wrapped with
MAX(length, 0)
to avoid negative value. Please tell me if these check can be removed.