Relying on various compiler primitives we can reduce the work done
in our memory allocators and CowData. For types with trivial ctors or
dtors we can skip looping over all elements when creating, resizing,
and destroying lists of objects.
These primitives are supported by clang, msvc, and GCC. However, once
we've moved to C++11 we can rely on several std:: primitives that do
the same thing and are standardized.
In my testing the extra conditionals introduced here get removed from
the generated program entirely as the results for these primitives is
known at compile time.
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
When compiling with VC++ 2017, Godot generates huge numbers of
C4291 warnings about missing placement delete.
I have not found a way to disable these warnings using compiler
options: AFAICT there is no equivalent to `-f-no-exceptions` for
VC++ (there is only /EH to change the exception-handling model,
/GX is deprecated) and adding /wd4291 to the
`disable_nonessential_warnings` list in the `SConstruct` file
or even compiling with `warnings=no` does not disable the
messages.
Placement delete is only called when placement new throws an
exception, since Godot doesn't use exceptions this change should
have no runtime effect.
Fixes#12654 (probably, difficult to say without log)
Plus:
- An allocation is counted only after checking its success.
- Max usage is updated after growing reallocs as well.
- Drop unused header.
- Changed the 0xFFF.. at get_mem_available() to -1 with a comment telling it's the same, but more universal.
The allocation count is managed atomically and where it actually should
change (for instance, not counting an allocation before its success has
been checked).
Bonus: Improve readability of the pre-pad checks.
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
That year should bring the long-awaited OpenGL ES 3.0 compatible renderer
with state-of-the-art rendering techniques tuned to work as low as middle
end handheld devices - without compromising with the possibilities given
for higher end desktop games of course. Great times ahead for the Godot
community and the gamers that will play our games!