aboutsummaryrefslogtreecommitdiff
path: root/include/irrArray.h
diff options
context:
space:
mode:
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>2022-01-22 15:54:43 +0000
committersfan5 <sfan5@live.de>2022-02-09 19:06:19 +0100
commit8c0ee7d9ab78714c261b500cd21639d292fdb32c (patch)
tree1a6ba8af65e7915011cfb06c5703d4de0f7b0c08 /include/irrArray.h
parent684293f5274a6b80b1596f4ea1189d702a0fcb2b (diff)
downloadirrlicht-8c0ee7d9ab78714c261b500cd21639d292fdb32c.tar.xz
Avoid some warnings from static code analysis.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6296 dfc29bdd-3216-0410-991c-e03cc46cb475
Diffstat (limited to 'include/irrArray.h')
-rw-r--r--include/irrArray.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/irrArray.h b/include/irrArray.h
index b133b62..99ecb2d 100644
--- a/include/irrArray.h
+++ b/include/irrArray.h
@@ -299,22 +299,27 @@ public:
return *this;
strategy = other.strategy;
+ // (TODO: we could probably avoid re-allocations of data when (allocated < other.allocated)
+
if (data)
clear();
- //if (allocated < other.allocated)
- if (other.allocated == 0)
- data = 0;
- else
- data = allocator.allocate(other.allocated); // new T[other.allocated];
-
used = other.used;
free_when_destroyed = true;
is_sorted = other.is_sorted;
allocated = other.allocated;
- for (u32 i=0; i<other.used; ++i)
- allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
+ if (other.allocated == 0)
+ {
+ data = 0;
+ }
+ else
+ {
+ data = allocator.allocate(other.allocated); // new T[other.allocated];
+
+ for (u32 i=0; i<other.used; ++i)
+ allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
+ }
return *this;
}