diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 18:36:58 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 18:36:58 +0400 |
commit | bea14e8aaa518313a5ca851a0302db5649e6328b (patch) | |
tree | 2bdf64ea8bbb1c533db5c2a1e29e7b86aa1f1259 /source/blender/blenkernel/intern/idprop.c | |
parent | a5dd469a06f15cdf3ec0bfc6c2cb18ba5bba9209 (diff) |
Fix slow resizing of ID property arrays with more than 1619 items, it incorrectly
reverted to sizing with by 1 each time. This was slowing down painting long strokes
with small brush radius.
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index ca1ae23c364..f60823edcc8 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -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*/ - 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. - */ |