From f8fc3380197c078a6dcff02351d835c3022411e1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Sep 2012 18:38:56 +0300 Subject: Improve inventory resize speed. --- src/gui/widgets/itemcontainer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 19f35ff02..aa254c30b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -541,24 +541,27 @@ void ItemContainer::updateMatrix() break; } + int jMult = j * mGridColumns; + const int maxSize = mGridRows * mGridColumns; for (std::vector::const_iterator iter = sortedItems.begin(), iter_end = sortedItems.end(); iter != iter_end; ++ iter) { - if (j >= mGridRows) + if (jMult >= maxSize) break; - mShowMatrix[j * mGridColumns + i] = (*iter)->mId; + mShowMatrix[jMult + i] = (*iter)->mId; i ++; if (i >= mGridColumns) { i = 0; j ++; + jMult += mGridColumns; } } for (int idx = j * mGridColumns + i; - idx < mGridRows * mGridColumns; idx ++) + idx < maxSize; idx ++) { mShowMatrix[idx] = -1; } -- cgit v1.2.3-70-g09d2