[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master e26d308 09/10: Remove undesirable 'default:'
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master e26d308 09/10: Remove undesirable 'default:' from 'switch' |
Date: |
Thu, 8 Feb 2018 08:40:11 -0500 (EST) |
branch: master
commit e26d308cacb7a28a4fe160d6786952238d7bf546
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Remove undesirable 'default:' from 'switch'
These are changes that call for more careful review because they involve
subtler changes or extensive reformatting.
---
actuarial_table.cpp | 12 +++---------
group_values.cpp | 12 +-----------
ihs_irc7702.cpp | 16 +++-------------
ledger_invariant.cpp | 28 +++-------------------------
rounding_view_editor.cpp | 5 +++--
5 files changed, 13 insertions(+), 60 deletions(-)
diff --git a/actuarial_table.cpp b/actuarial_table.cpp
index 63b8ff9..8291fda 100644
--- a/actuarial_table.cpp
+++ b/actuarial_table.cpp
@@ -169,18 +169,12 @@ std::vector<double> actuarial_table::values_elaborated
return v;
}
// break;
- case e_reenter_never: // Fall through.
- default:
+ case e_reenter_never:
{
- alarum()
- << "Table-lookup method "
- << method
- << " is not valid in this context."
- << LMI_FLUSH
- ;
- throw "Unreachable--silences a compiler diagnostic.";
+ alarum() << "Cannot use 'e_reenter_never' here." << LMI_FLUSH;
}
}
+ throw "Unreachable--silences a compiler diagnostic.";
}
/// Find the table specified by table_number_.
diff --git a/group_values.cpp b/group_values.cpp
index 6678cde..f66611e 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -694,8 +694,7 @@ census_run_result run_census::operator()
// Use the first cell's run order for the entire census, ignoring
// any conflicting run order for any other cell--which would have
// been prevented upstream by assert_consistent_run_order().
- mcenum_run_order order = yare_input(cells[0]).RunOrder;
- switch(order)
+ switch(yare_input(cells[0]).RunOrder)
{
case mce_life_by_life:
{
@@ -717,15 +716,6 @@ census_run_result run_census::operator()
);
}
break;
- default:
- {
- alarum()
- << "Case "
- << order
- << " not found."
- << LMI_FLUSH
- ;
- }
}
// Indicate cancellation on the statusbar. This may be of little
diff --git a/ihs_irc7702.cpp b/ihs_irc7702.cpp
index 1b24fd6..176c84a 100644
--- a/ihs_irc7702.cpp
+++ b/ihs_irc7702.cpp
@@ -827,20 +827,10 @@ Irc7702::EIOBasis Irc7702::Get4PctBasis
{
switch(a_DBOpt)
{
- case mce_option1_for_7702:
- {
- return Opt1Int4Pct;
- }
- case mce_option2_for_7702:
- {
- return Opt2Int4Pct;
- }
- default:
- {
- alarum() << "Case '" << a_DBOpt << "' not found." << LMI_FLUSH;
- throw "Unreachable--silences a compiler diagnostic.";
- }
+ case mce_option1_for_7702: return Opt1Int4Pct;
+ case mce_option2_for_7702: return Opt2Int4Pct;
}
+ throw "Unreachable--silences a compiler diagnostic.";
}
//============================================================================
diff --git a/ledger_invariant.cpp b/ledger_invariant.cpp
index 6c2758d..2d40216 100644
--- a/ledger_invariant.cpp
+++ b/ledger_invariant.cpp
@@ -851,31 +851,9 @@ void LedgerInvariant::Init(BasicValues const* b)
{
switch(b->yare_input_.Smoking)
{
- case mce_smoker:
- {
- Smoker = "Tobacco";
- }
- break;
- case mce_nonsmoker:
- {
- Smoker = "Nontobacco";
- }
- break;
- case mce_unismoke:
- {
- Smoker = "Unitobacco";
- }
- break;
- default:
- {
- alarum()
- << "Case '"
- << smoke_or_tobacco
- << "' not found."
- << LMI_FLUSH
- ;
- }
- break;
+ case mce_smoker: Smoker = "Tobacco"; break;
+ case mce_nonsmoker: Smoker = "Nontobacco"; break;
+ case mce_unismoke: Smoker = "Unitobacco"; break;
}
}
else if(oe_smoker_nonsmoker == smoke_or_tobacco)
diff --git a/rounding_view_editor.cpp b/rounding_view_editor.cpp
index 68a5ca8..7eebbca 100644
--- a/rounding_view_editor.cpp
+++ b/rounding_view_editor.cpp
@@ -266,9 +266,10 @@ void RoundingButtons::DiscardEdits()
void RoundingButtons::UponButtonClick( wxCommandEvent & event )
{
- int id = event.GetId();
rounding_style style;
- switch(id)
+ // This switch condition is not of enumerative type. The default
+ // case is necessary for values that match none of the enumerators.
+ switch(event.GetId())
{
case e_rbi_not_at_all:
style = r_not_at_all;
- [lmi-commits] [lmi] master updated (eafa74e -> 246f754), Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 9cc3f6b 05/10: Avoid passing an enum by reference, Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 20e866a 06/10: Simplify an overwrought expression, Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master b0576c8 02/10: Remove undesirable 'default:' from 'switch', Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master e26d308 09/10: Remove undesirable 'default:' from 'switch',
Greg Chicares <=
- [lmi-commits] [lmi] master 422e64a 03/10: Remove an unimplemented 'case', Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 92911ca 07/10: Improve documentation, Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 9797cbc 04/10: Remove undesirable 'default:' from 'switch', Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 78fd8b8 01/10: Remove undesirable 'default:' from 'switch', Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 246f754 10/10: In unit tests, reflect removal of undesirable 'default:' from 'switch', Greg Chicares, 2018/02/08
- [lmi-commits] [lmi] master 3952bd0 08/10: Remove undesirable 'default:' from 'switch', Greg Chicares, 2018/02/08