You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it. From now on writes to Vectors need to happen through the .write proxy. So for instance: Vector<int> vec; vec.push_back(10); std::cout << vec[0] << std::endl; vec.write[0] = 20; Failing to use the .write proxy will cause a compilation error. In addition COWable datatypes can now embed a CowData pointer to their data. This means that String, CharString, and VMap no longer use or derive from Vector. _ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug builds. This is a lot faster for Vector in the editor and while running tests. The reason why this difference used to exist is because force-inlined methods used to give a bad debugging experience. After extensive testing with modern compilers this is no longer the case.
This commit is contained in:
@@ -1333,7 +1333,7 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
|
||||
bool is_present = onion.differences_only && i == captures - 1;
|
||||
|
||||
// Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport
|
||||
onion.captures[i] = VS::get_singleton()->viewport_create();
|
||||
onion.captures.write[i] = VS::get_singleton()->viewport_create();
|
||||
VS::get_singleton()->viewport_set_usage(onion.captures[i], VS::VIEWPORT_USAGE_2D);
|
||||
VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
|
||||
VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS);
|
||||
@@ -1473,7 +1473,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
||||
float pos = cpos + step_off * anim->get_step();
|
||||
|
||||
bool valid = anim->has_loop() || (pos >= 0 && pos <= anim->get_length());
|
||||
onion.captures_valid[cidx] = valid;
|
||||
onion.captures_valid.write[cidx] = valid;
|
||||
if (valid) {
|
||||
player->seek(pos, true);
|
||||
get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials
|
||||
|
||||
Reference in New Issue
Block a user