]> git.lizzy.rs Git - irrlicht.git/commitdiff
Avoid some warnings from static code analysis.
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>
Sat, 22 Jan 2022 15:54:43 +0000 (15:54 +0000)
committersfan5 <sfan5@live.de>
Wed, 9 Feb 2022 18:06:19 +0000 (19:06 +0100)
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6296 dfc29bdd-3216-0410-991c-e03cc46cb475

include/irrArray.h

index b133b62d2da5480ea77bdb843ace081775ef332a..99ecb2de22776fad51c4333b3a19d810a1a3509e 100644 (file)
@@ -299,22 +299,27 @@ public:
                        return *this;\r
                strategy = other.strategy;\r
 \r
+               // (TODO: we could probably avoid re-allocations of data when (allocated < other.allocated)\r
+\r
                if (data)\r
                        clear();\r
 \r
-               //if (allocated < other.allocated)\r
-               if (other.allocated == 0)\r
-                       data = 0;\r
-               else\r
-                       data = allocator.allocate(other.allocated); // new T[other.allocated];\r
-\r
                used = other.used;\r
                free_when_destroyed = true;\r
                is_sorted = other.is_sorted;\r
                allocated = other.allocated;\r
 \r
-               for (u32 i=0; i<other.used; ++i)\r
-                       allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];\r
+               if (other.allocated == 0)\r
+               {\r
+                       data = 0;\r
+               }\r
+               else\r
+               {\r
+                       data = allocator.allocate(other.allocated); // new T[other.allocated];\r
+\r
+                       for (u32 i=0; i<other.used; ++i)\r
+                               allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];\r
+               }\r
 \r
                return *this;\r
        }\r