lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/zero_columns e5b9a61 7/7: Remove an unnecessary


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/zero_columns e5b9a61 7/7: Remove an unnecessary early-return statement
Date: Mon, 6 May 2019 07:21:25 -0400 (EDT)

branch: odd/zero_columns
commit e5b9a61df087dbdffd584361cde7139ab298ef08
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Remove an unnecessary early-return statement
    
    Rewrote comments on the remaining early-return statements to clarify
    the questions they raise.
    
    Now this branch differs only minimally from origin/master, and running
    this reproducible test case:
    
      File | New | Census
      Census | Edit cell
        "Reports" tab:
        check "Create supplemental report"
        OK
      Census | Add cell
      Census | Run case
      File | Print to PDF
    
    succeeds in this branch but fails in origin/master. The question is
    whether these two early return statement
     - are desirable, or
     - indication precondition violations in their callers.
---
 wx_table_generator.cpp | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 50f714e..fa0f6e6 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -177,9 +177,6 @@ void wx_table_generator::output_headers
     ,oenum_render_or_only_measure output_mode
     )
 {
-    // Does this added line prevent any actual problem?
-    if(0 == lmi::ssize(all_columns_)) return;
-
     int const anticipated_pos_y =
           pos_y
         + draw_separators_
@@ -383,11 +380,11 @@ void wx_table_generator::output_horz_separator
 
     if(!(begin_column < end_column))
         {
-        // This assertion really would fail. Is
-        //   begin_column < end_column
-        // a precondition?
         warning() << "assertion would have failed" << LMI_FLUSH; return;
         }
+    // This assertion really would fail. Is
+    //   begin_column < end_column
+    // a precondition?
     LMI_ASSERT(begin_column < end_column);
     LMI_ASSERT(end_column <= lmi::ssize(all_columns()));
 
@@ -431,8 +428,10 @@ wxRect wx_table_generator::external_text_rect(int 
a_column, int y) const
 
 wxRect wx_table_generator::text_rect(int column, int y) const
 {
-    // Does this added line prevent any actual problem?
     if(!(column < lmi::ssize(all_columns()))) return wxRect{};
+    // This assertion really would fail. Is
+    //   column < lmi::ssize(all_columns())
+    // a precondition?
     LMI_ASSERT(column < lmi::ssize(all_columns()));
     wxRect z = cell_rect(column, y).Deflate(dc().GetCharWidth(), 0);
     z.Offset(0, (row_height_ - char_height_)/2);



reply via email to

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