Fix slow resizing of ID property arrays with more than 1619 items, it incorrectly
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 May 2013 14:36:58 +0000 (14:36 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 May 2013 14:36:58 +0000 (14:36 +0000)
reverted to sizing with by 1 each time. This was slowing down painting long strokes
with small brush radius.

source/blender/blenkernel/intern/idprop.c

index ca1ae23c364ffbc2fc08ab745de1d9b9754c738d..f60823edcc8de75659e492734c0953ad19d44526 100644 (file)
@@ -138,14 +138,20 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
 
        /*first check if the array buffer size has room*/
        /*if newlen is 200 chars less then totallen, reallocate anyway*/
 
        /*first check if the array buffer size has room*/
        /*if newlen is 200 chars less then totallen, reallocate anyway*/
-       if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
-               int i;
+       if (newlen <= prop->totallen) {
+               if (newlen < prop->len && prop->totallen - newlen < 200) {
+                       int i;
 
 
-               for (i = newlen; i < prop->len; i++)
-                       IDP_FreeProperty(GETPROP(prop, i));
+                       for (i = newlen; i < prop->len; i++)
+                               IDP_FreeProperty(GETPROP(prop, i));
 
 
-               prop->len = newlen;
-               return;
+                       prop->len = newlen;
+                       return;
+               }
+               else if (newlen >= prop->len) {
+                       prop->len = newlen;
+                       return;
+               }
        }
 
        /* - Note: This code comes from python, here's the corresponding comment. - */
        }
 
        /* - Note: This code comes from python, here's the corresponding comment. - */