]> git.lizzy.rs Git - irrlicht.git/blobdiff - include/irrArray.h
Avoid some warnings from static code analysis.
[irrlicht.git] / 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