Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/util/util_vector.h')
-rw-r--r--intern/cycles/util/util_vector.h44
1 files changed, 39 insertions, 5 deletions
diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h
index 546b17570bb..e98e4e34181 100644
--- a/intern/cycles/util/util_vector.h
+++ b/intern/cycles/util/util_vector.h
@@ -23,9 +23,9 @@
#include <cstring>
#include <vector>
-#include "util_aligned_malloc.h"
-#include "util_guarded_allocator.h"
-#include "util_types.h"
+#include "util/util_aligned_malloc.h"
+#include "util/util_guarded_allocator.h"
+#include "util/util_types.h"
CCL_NAMESPACE_BEGIN
@@ -86,9 +86,9 @@ public:
* this was actually showing up in profiles quite significantly. it
* also does not run any constructors/destructors
* - if this is used, we are not tempted to use inefficient operations
- * - aligned allocation for SSE data types */
+ * - aligned allocation for CPU native data types */
-template<typename T, size_t alignment = 16>
+template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES>
class array
{
public:
@@ -162,6 +162,11 @@ public:
return memcmp(data_, other.data_, datasize_*sizeof(T)) == 0;
}
+ bool operator!=(const array<T>& other) const
+ {
+ return !(*this == other);
+ }
+
void steal_data(array& from)
{
if(this != &from) {
@@ -177,6 +182,14 @@ public:
}
}
+ T *steal_pointer()
+ {
+ T *ptr = data_;
+ data_ = NULL;
+ clear();
+ return ptr;
+ }
+
T* resize(size_t newsize)
{
if(newsize == 0) {
@@ -202,6 +215,18 @@ public:
return data_;
}
+ T* resize(size_t newsize, const T& value)
+ {
+ size_t oldsize = size();
+ resize(newsize);
+
+ for(size_t i = oldsize; i < size(); i++) {
+ data_[i] = value;
+ }
+
+ return data_;
+ }
+
void clear()
{
if(data_ != NULL) {
@@ -273,6 +298,15 @@ public:
push_back_slow(t);
}
+ void append(const array<T>& from)
+ {
+ if(from.size()) {
+ size_t old_size = size();
+ resize(old_size + from.size());
+ memcpy(data_ + old_size, from.data(), sizeof(T) * from.size());
+ }
+ }
+
protected:
inline T* mem_allocate(size_t N)
{