lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 9e1ac25 09/12: Fold a "ternary" conditional i


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 9e1ac25 09/12: Fold a "ternary" conditional into a switch
Date: Tue, 22 May 2018 17:09:22 -0400 (EDT)

branch: master
commit 9e1ac25ca5372ad4888208789e492f1f338bc543
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Fold a "ternary" conditional into a switch
    
    The 'widest_text.empty()' condition has been replaced by the explicit
    elastic-inelastic dichotomy. It is clearer to test the condition OAOO
    and write one block for each set of conditionally-executed statements.
    
    Wrote temporary assertions to ensure that the conditions are aligned
    correctly. They'll be expunged without comment in the next commit.
---
 wx_table_generator.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index f10f036..c3b12eb 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -307,9 +307,6 @@ void wx_table_generator::enroll_column(column_parameters 
const& z)
             header_font_setter.Set(get_header_font());
             }
 
-        // Set width to the special value of 0 for the elastic columns.
-        width = z.widest_text.empty() ? 0 : dc_.GetTextExtent(z.widest_text).x;
-
         wxCoord w, h, lh;
         dc_.GetMultiLineTextExtent(z.header, &w, &h, &lh, &dc_.GetFont());
         LMI_ASSERT(0 != lh);
@@ -326,6 +323,8 @@ LMI_ASSERT(std::size_t(h / lh) == 1u + 
count_newlines(z.header));
             {
             case oe_inelastic:
                 {
+LMI_ASSERT(!z.widest_text.empty()); // To be removed in the next commit.
+                width = dc_.GetTextExtent(z.widest_text).x;
                 // Also increase the column width to be sufficiently wide to 
fit
                 // this header line if it is inelastic.
                 increase_to_if_smaller(width, w);
@@ -334,6 +333,9 @@ LMI_ASSERT(std::size_t(h / lh) == 1u + 
count_newlines(z.header));
                 break;
             case oe_elastic:
                 {
+LMI_ASSERT(z.widest_text.empty()); // To be removed in the next commit.
+                // Set width to the special value of 0 for the elastic columns.
+                width = 0;
                 }
                 break;
             }



reply via email to

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