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.
This commit is contained in:
Brecht Van Lommel
2013-05-15 14:36:58 +00:00
parent a5dd469a06
commit bea14e8aaa

View File

@@ -138,7 +138,8 @@ 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) {
if (newlen <= prop->totallen) {
if (newlen < prop->len && prop->totallen - newlen < 200) {
int i;
for (i = newlen; i < prop->len; i++)
@@ -147,6 +148,11 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
prop->len = newlen;
return;
}
else if (newlen >= prop->len) {
prop->len = newlen;
return;
}
}
/* - Note: This code comes from python, here's the corresponding comment. - */
/* This over-allocates proportional to the list size, making room