Explorar el Código

Fix the inconsistent behavior between Spine vector's setSize and std::vector's resize, which causes the Spine vector to allocate additional space upfront. (#2830)

bofeng-song hace 4 meses
padre
commit
7fd1e5340c
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      spine-cpp/spine-cpp/include/spine/Vector.h

+ 5 - 1
spine-cpp/spine-cpp/include/spine/Vector.h

@@ -77,7 +77,11 @@ namespace spine {
 			size_t oldSize = _size;
 			_size = newSize;
 			if (_capacity < newSize) {
-				_capacity = (int) (_size * 1.75f);
+				if (_capacity == 0) {
+					_capacity = _size;
+				} else {
+					_capacity = (int) (_size * 1.75f);
+				}
 				if (_capacity < 8) _capacity = 8;
 				_buffer = spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
 			}