Fix some MSVC warnings #500
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minor changes to reduce the number of compile warnings emitted. I'm using VMA in a unity build with MSVC and fairly strict compile settings in Debug mode. I saw it mentioned before that fixing compile warnings isn't considered important (Understandably), so it's fine to close the PR if the changes are considered against the preferences of the project.
Overview:
VmaVector<T, AllocatorT>::resize
remove ternary branch as it should not be possible fornewCapacity
to be 0. Apart from removing an unnecessary branch and clearing up intent, it removes a warning about potentially passing NULL as input tomemcpy
, which is undefined behavior.Notes:
VMA_LEAK_LOG_FORMAT
which may not may not expand to an expression. I figured it was still better to include them if warnings about unused variables aren't considered useful anyways, at least it reduces build noise.VmaVector<T, AllocatorT>::resize
will allocate a new buffer and copy over the contents even if the new capacity is less than the current. I don't know if there's an easy way to just shrink the allocation in such a case to avoid the overhead of allocating a new buffer and doing amemcpy
. I didn't look into it for this PR.