lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master b3ac65b 43/46: Allow wxGrid to compute census


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b3ac65b 43/46: Allow wxGrid to compute census view column sizes more efficiently
Date: Wed, 22 Jul 2020 11:05:17 -0400 (EDT)

branch: master
commit b3ac65ba860bd5f30c4ce09bdd4abf283a2566f4
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>

    Allow wxGrid to compute census view column sizes more efficiently
    
    Override the recently introduced CanMeasureColUsingSameAttr() to
    indicate that there is no need to re-query each row for its own
    attribute when the same one can be used for measuring the widths of all
    of them.
    
    This results in significant speedup for the censuses with many rows
    (more than 2x for the total time of switching to varying width columns
    for ~4000 rows, for example).
---
 census_view.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/census_view.cpp b/census_view.cpp
index ed4a953..0910b75 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1502,6 +1502,8 @@ class CensusViewGridTable
 
     wxString GetColLabelValue(int col) override;
 
+    bool CanMeasureColUsingSameAttr(int col) const override;
+
     std::string const& col_name(int col) const;
 
     Input& row_at(int row);
@@ -1611,6 +1613,15 @@ wxString CensusViewGridTable::GetColLabelValue(int col)
     return insert_spaces_between_words(header);
 }
 
+bool CensusViewGridTable::CanMeasureColUsingSameAttr(int) const
+{
+    // All our columns use the same type and practically the same attribute:
+    // only its background colour varies, but the colour doesn't matter for
+    // measuring, so we can always return true from here and allow wxGrid to
+    // reuse the same attribute for the entire column.
+    return true;
+}
+
 bool CensusViewGridTable::AppendRows(size_t numRows)
 {
     auto grid = GetView();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]