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

Don't use constant reference in Vector push_back, insert and append_array #34618

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

qarmin
Copy link
Contributor

@qarmin qarmin commented Dec 26, 2019

Fixes #31159 and similar

Test project - Line.zip - To see errors Valgrind or Address Sanitizer should be used

Reduz explanation from #31609 (comment)

Sorry, this should have been fixed long ago, we even discussed it at the beginning of the year.

I suggest just make a PR that changes this:

bool Vector<T>::push_back(const T &p_elem) 
to this
bool Vector<T>::push_back(T p_elem) 

It should be fine performance wise, the rational is that in far most cases (Specially where performance is required), Godot uses types that are 8 bytes or less, which is just the same as a pointer. This is fast because it will fit on a CPU register or cache. For larger datatypes, this is not really something critically performant anyway because a good amount of bytes has to be copied or a copy constructor needs to be run, so it should not matter much if it does a copy.

@qarmin
Copy link
Contributor Author

qarmin commented Dec 26, 2019

I changed file editor/import/editor_scene_importer_gltf.h because travis complains about unitialized variable

./core/cowdata.h:140:3: error: 'accessor.EditorSceneImporterGLTF::GLTFAccessor::sparse_indices_buffer_view' may be used uninitialized in this function [-Werror=maybe-uninitialized]

@akien-mga
Copy link
Member

Both @hpvb and @reduz say that it seems fine as a short term fix for 3.2, unless Vector can be further refactored to avoid this issue altogether.

@akien-mga akien-mga merged commit bde52cc into godotengine:master Jan 2, 2020
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

Autoloads and engine singletons sometimes are considered "freed"
3 participants