[Bf-blender-cvs] [16a23f4195e] functions: rename FixedArrayAllocator to just ArrayAllocator
Jacques Lucke
noreply at git.blender.org
Mon Jul 8 17:56:46 CEST 2019
Commit: 16a23f4195ee9b6f17a7c9c81f7a539d468e4fd5
Author: Jacques Lucke
Date: Mon Jul 8 11:44:21 2019 +0200
Branches: functions
https://developer.blender.org/rB16a23f4195ee9b6f17a7c9c81f7a539d468e4fd5
rename FixedArrayAllocator to just ArrayAllocator
===================================================================
R089 source/blender/blenlib/BLI_fixed_array_allocator.hpp source/blender/blenlib/BLI_array_allocator.hpp
M source/blender/blenlib/CMakeLists.txt
M source/blender/simulations/bparticles/attributes.cpp
M source/blender/simulations/bparticles/attributes.hpp
M source/blender/simulations/bparticles/simulate.cpp
R074 tests/gtests/blenlib/BLI_fixed_array_allocator_test.cc tests/gtests/blenlib/BLI_array_allocator_test.cc
M tests/gtests/blenlib/CMakeLists.txt
===================================================================
diff --git a/source/blender/blenlib/BLI_fixed_array_allocator.hpp b/source/blender/blenlib/BLI_array_allocator.hpp
similarity index 89%
rename from source/blender/blenlib/BLI_fixed_array_allocator.hpp
rename to source/blender/blenlib/BLI_array_allocator.hpp
index 5550adcb23a..34a9d773be8 100644
--- a/source/blender/blenlib/BLI_fixed_array_allocator.hpp
+++ b/source/blender/blenlib/BLI_array_allocator.hpp
@@ -11,7 +11,7 @@
namespace BLI {
-class FixedArrayAllocator {
+class ArrayAllocator {
private:
SmallVector<void *, 16> m_all_pointers;
SmallVector<SmallStack<void *>, 16> m_pointer_stacks;
@@ -22,13 +22,13 @@ class FixedArrayAllocator {
* Create a new allocator that will allocate arrays with the given length (the element size may
* vary).
*/
- FixedArrayAllocator(uint array_length) : m_array_length(array_length)
+ ArrayAllocator(uint array_length) : m_array_length(array_length)
{
}
- FixedArrayAllocator(FixedArrayAllocator &other) = delete;
+ ArrayAllocator(ArrayAllocator &other) = delete;
- ~FixedArrayAllocator()
+ ~ArrayAllocator()
{
for (void *ptr : m_all_pointers) {
MEM_freeN(ptr);
@@ -88,12 +88,12 @@ class FixedArrayAllocator {
*/
template<typename T> class ScopedAllocation {
private:
- FixedArrayAllocator &m_allocator;
+ ArrayAllocator &m_allocator;
void *m_ptr;
uint m_element_size;
public:
- ScopedAllocation(FixedArrayAllocator &allocator, T *ptr, uint element_size)
+ ScopedAllocation(ArrayAllocator &allocator, T *ptr, uint element_size)
: m_allocator(allocator), m_ptr(ptr), m_element_size(element_size)
{
}
@@ -125,7 +125,7 @@ class FixedArrayAllocator {
return (T *)m_ptr;
}
- FixedArrayAllocator &allocator()
+ ArrayAllocator &allocator()
{
return m_allocator;
}
@@ -155,7 +155,7 @@ class FixedArrayAllocator {
VectorAdaptor<T> m_vector;
public:
- Vector(FixedArrayAllocator &allocator)
+ Vector(ArrayAllocator &allocator)
: m_ptr(allocator.allocate_scoped<T>()), m_vector(m_ptr, allocator.array_size())
{
}
@@ -179,11 +179,11 @@ class FixedArrayAllocator {
uint m_size;
public:
- Array(FixedArrayAllocator &allocator) : Array(allocator, allocator.array_size())
+ Array(ArrayAllocator &allocator) : Array(allocator, allocator.array_size())
{
}
- Array(FixedArrayAllocator &allocator, uint size)
+ Array(ArrayAllocator &allocator, uint size)
: m_ptr(allocator.allocate_scoped<T>()), m_size(size)
{
BLI_assert(size <= allocator.array_size());
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 2ce6d1871ae..4c07a7744c1 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -234,11 +234,11 @@ set(SRC
PIL_time.h
PIL_time_utildefines.h
+ BLI_array_allocator.hpp
BLI_array_lookup.hpp
BLI_array_ref.hpp
BLI_chained_strings.hpp
BLI_composition.hpp
- BLI_fixed_array_allocator.hpp
BLI_lazy_init.h
BLI_lazy_init.hpp
intern/BLI_lazy_init.cpp
diff --git a/source/blender/simulations/bparticles/attributes.cpp b/source/blender/simulations/bparticles/attributes.cpp
index 35c93191a4f..3a7e25d66e6 100644
--- a/source/blender/simulations/bparticles/attributes.cpp
+++ b/source/blender/simulations/bparticles/attributes.cpp
@@ -48,7 +48,7 @@ AttributeArraysCore AttributeArraysCore::NewWithSeparateAllocations(AttributesIn
}
AttributeArraysCore AttributeArraysCore::NewWithArrayAllocator(AttributesInfo &info,
- FixedArrayAllocator &allocator)
+ ArrayAllocator &allocator)
{
SmallVector<void *> arrays;
for (AttributeType type : info.types()) {
@@ -66,7 +66,7 @@ void AttributeArraysCore::free_buffers()
}
}
-void AttributeArraysCore::deallocate_in_array_allocator(FixedArrayAllocator &allocator)
+void AttributeArraysCore::deallocate_in_array_allocator(ArrayAllocator &allocator)
{
for (uint i = 0; i < m_arrays.size(); i++) {
void *ptr = m_arrays[i];
diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp
index 04fbc931828..295a3676372 100644
--- a/source/blender/simulations/bparticles/attributes.hpp
+++ b/source/blender/simulations/bparticles/attributes.hpp
@@ -8,12 +8,12 @@
#include "BLI_string_ref.hpp"
#include "BLI_range.hpp"
#include "BLI_small_set_vector.hpp"
-#include "BLI_fixed_array_allocator.hpp"
+#include "BLI_array_allocator.hpp"
namespace BParticles {
+using BLI::ArrayAllocator;
using BLI::ArrayRef;
-using BLI::FixedArrayAllocator;
using BLI::float3;
using BLI::Range;
using BLI::SmallSetVector;
@@ -241,12 +241,12 @@ class AttributeArraysCore {
* allocates arrays of one specific length.
*/
static AttributeArraysCore NewWithArrayAllocator(AttributesInfo &info,
- FixedArrayAllocator &allocator);
+ ArrayAllocator &allocator);
/**
* Deallocate pointers in the given fixed-array-allocator.
*/
- void deallocate_in_array_allocator(FixedArrayAllocator &allocator);
+ void deallocate_in_array_allocator(ArrayAllocator &allocator);
/**
* Get information about the stored attributes.
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 3fd9973c89e..d709877de88 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -221,7 +221,7 @@ BLI_NOINLINE static void execute_events(BlockAllocator &block_allocator,
}
}
-BLI_NOINLINE static void simulate_to_next_event(FixedArrayAllocator &array_allocator,
+BLI_NOINLINE static void simulate_to_next_event(ArrayAllocator &array_allocator,
BlockAllocator &block_allocator,
ParticleSet particles,
AttributeArrays attribute_offsets,
@@ -234,10 +234,10 @@ BLI_NOINLINE static void simulate_to_next_event(FixedArrayAllocator &array_alloc
uint amount = particles.size();
BLI_assert(array_allocator.array_size() >= amount);
- FixedArrayAllocator::Array<int> next_event_indices(array_allocator, amount);
- FixedArrayAllocator::Array<float> time_factors_to_next_event(array_allocator, amount);
- FixedArrayAllocator::Vector<uint> indices_with_event(array_allocator);
- FixedArrayAllocator::Vector<uint> particle_indices_with_event(array_allocator);
+ ArrayAllocator::Array<int> next_event_indices(array_allocator, amount);
+ ArrayAllocator::Array<float> time_factors_to_next_event(array_allocator, amount);
+ ArrayAllocator::Vector<uint> indices_with_event(array_allocator);
+ ArrayAllocator::Vector<uint> particle_indices_with_event(array_allocator);
uint max_event_storage_size = std::max(get_max_event_storage_size(events), 1u);
auto event_storage_array = array_allocator.allocate_scoped(max_event_storage_size);
@@ -293,7 +293,7 @@ BLI_NOINLINE static void simulate_to_next_event(FixedArrayAllocator &array_alloc
BLI_NOINLINE static void simulate_with_max_n_events(
uint max_events,
- FixedArrayAllocator &array_allocator,
+ ArrayAllocator &array_allocator,
BlockAllocator &block_allocator,
ParticlesBlock &block,
AttributeArrays attribute_offsets,
@@ -402,7 +402,7 @@ BLI_NOINLINE static void apply_remaining_offsets(ParticleSet particles,
}
}
-BLI_NOINLINE static void simulate_block(FixedArrayAllocator &array_allocator,
+BLI_NOINLINE static void simulate_block(ArrayAllocator &array_allocator,
BlockAllocator &block_allocator,
ParticlesBlock &block,
ParticleType &particle_type,
@@ -491,7 +491,7 @@ class BlockAllocators {
};
struct ThreadLocalData {
- FixedArrayAllocator array_allocator;
+ ArrayAllocator array_allocator;
BlockAllocator &block_allocator;
ThreadLocalData(uint block_size, BlockAllocator &block_allocator)
diff --git a/tests/gtests/blenlib/BLI_fixed_array_allocator_test.cc b/tests/gtests/blenlib/BLI_array_allocator_test.cc
similarity index 74%
rename from tests/gtests/blenlib/BLI_fixed_array_allocator_test.cc
rename to tests/gtests/blenlib/BLI_array_allocator_test.cc
index dd814cd54ad..17926c9751c 100644
--- a/tests/gtests/blenlib/BLI_fixed_array_allocator_test.cc
+++ b/tests/gtests/blenlib/BLI_array_allocator_test.cc
@@ -1,11 +1,11 @@
#include "testing/testing.h"
-#include "BLI_fixed_array_allocator.hpp"
+#include "BLI_array_allocator.hpp"
-using BLI::FixedArrayAllocator;
+using BLI::ArrayAllocator;
TEST(fixed_array_allocator, AllocateSameSize)
{
- FixedArrayAllocator allocator(42);
+ ArrayAllocator allocator(42);
void *ptr1 = allocator.allocate(4);
void *ptr2 = allocator.allocate(4);
EXPECT_NE(ptr1, ptr2);
@@ -13,7 +13,7 @@ TEST(fixed_array_allocator, AllocateSameSize)
TEST(fixed_array_allocator, AllocateDifferentSizes)
{
- FixedArrayAllocator allocator(42);
+ ArrayAllocator allocator(42);
void *ptr1 = allocator.allocate(3);
void *ptr2 = allocator.allocate(4);
EXPECT_NE(ptr1, ptr2);
@@ -21,7 +21,7 @@ TEST(fixed_array_allocator, AllocateDifferentSizes)
TEST(fixed_array_allocator, AllocateSamePointerTwice)
{
- FixedArrayAllocator allocator(42);
+ ArrayAllocator allocator(42);
void *ptr1 = allocator.allocate(10);
allocator.deallocate(ptr1, 10);
void *ptr2 = allocator.allocate(10);
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 0b38f22e0fe..524f7ec0faf 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -38,6 +38,7 @@ else()
set(BLI_path_util_extra_libs "bf_blenlib;extern_wcwidth;${ZLIB_LIBRARIES}")
endif()
+BLENDER_TEST(BLI_array_allocator "bf_blenlib")
BLENDER_TEST(BLI_array_lookup "bf_blenlib")
BLENDER_TEST(BLI_array_store "bf_blenlib")
BLENDER_TES
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list