-
-
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
Improve DynamicBVH code to make it clearer how the stack/heap works #86059
Improve DynamicBVH code to make it clearer how the stack/heap works #86059
Conversation
Looks to me like once If I'm right, a change that would communicate all that more clrearly would be to keep the original stack pointer as
|
Agree with @RandomShaper you seem to be misunderstanding how the code works. The alloca stack the OS stack, and the aux stack is actually the heap. |
This is true. I'm still new to the godot code base. I'll adjust the patch as suggested. I'm just trying to fix Coverity issues that make sense in the short term. |
No worries. Besides, I'd advise you to get more familiar with the codebase until the point where you start feeling comfortable catching and fixing issues yourself. Automated tools only get you so far (for now!) and can even hinder your self-training process. |
Inspired by a Coverity issue about possible memcpy usage and overlapping memory.
a3ef2ec
to
4653196
Compare
Updated and tested to the best I can. Advise on downloadable projects that would make sure I didn't break anything? |
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.
LGTM. I think this makes the intent of the code more explicit. Aside, I'm pretty sure the compiler will be good at removing the superfluous (to the machine) stuff.
Looks fine as far as I can see for functionality. Whether it improves readability I can't say, but then I'm quite used to this pattern (stack then heap) so am not an unbiased observer. |
Thanks! |
...
if (aux_stack.is_empty())
memcpy(aux_stack.ptr(), stack, ALLOCA_STACK_SIZE * sizeof(const Node *));
...
stack = aux_stack.ptr();
There might be a possibility that "aux_stack.ptr()" and "stack" will overlap. Using memmove will ensure in this case it's handled correctly.