commit 21f4c37a6637d4fbf3ad79bb14238f8e312c1dc0
parent f94f80c7bcc5e7db9dba8ae590f7dd87a12365a9
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 6 Jun 2017 00:03:48 -0400
listview: optimize insertion of items when view is sorted
ListView::translate was slowing down the loading of the package browser
by a lot on Windows.
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -81,17 +81,19 @@ int ListView::addRow(const Row &content)
ListView_InsertItem(handle(), &item);
m_rows.resize(item.iItem + 1); // make room for the new row
- replaceRow(item.iItem, content);
+ replaceRow(item.iItem, content, false);
return item.iItem;
}
-void ListView::replaceRow(int index, const Row &content)
+void ListView::replaceRow(int index, const Row &content, const bool isUserIndex)
{
assert(content.size() == m_cols.size());
m_rows[index] = content;
- index = translate(index);
+
+ if(isUserIndex)
+ index = translate(index);
for(int i = 0; i < columnCount(); i++) {
auto_char *text = const_cast<auto_char *>(content[i].c_str());
diff --git a/src/listview.hpp b/src/listview.hpp
@@ -58,7 +58,7 @@ public:
int addRow(const Row &);
const Row &row(int index) const { return m_rows[index]; }
- void replaceRow(int index, const Row &);
+ void replaceRow(int index, const Row &, bool userIndex = true);
void removeRow(int index);
int rowCount() const { return (int)m_rows.size(); }
bool empty() const { return rowCount() < 1; }