[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] [PATCH 2/3] Remove unused variables.
From: |
Václav Slavík |
Subject: |
Re: [lmi] [PATCH 2/3] Remove unused variables. |
Date: |
Wed, 1 Oct 2014 15:30:57 +0200 |
Hi,
On 01 Oct 2014, at 15:15, Greg Chicares <address@hidden> wrote:
> been an intentional means of "implicit" error checking; it's hard to
> prove that there was no such intention. You know Vaclav's style better
> than I do; what do you think he had in mind when he wrote this?
I think it’s a leftover from some changes to the code introduced after
as_enum/as_sequence were added. As far as I can track it down, the original
code looked like this:
+renderer_type_convertor const& renderer_type_convertor::get(any_member<Input>
const& value)
+{
+ mc_enum_base const* as_enum = NULL;
+ datum_sequence const* as_sequence = NULL;
+ tn_range_base const* as_range = NULL;
+
+ if(typeid(mce_yes_or_no Input::*) == value.type())
+ {
+ return get_impl<renderer_bool_convertor>();
+ }
+ else if(0 != (as_enum = try_member_cast<mc_enum_base>(value)))
+ {
+ return get_impl<renderer_enum_convertor>();
+ }
+ else if(0 != (as_sequence = try_member_cast<datum_sequence>(value)))
+ {
+ return get_impl<renderer_sequence_convertor>();
+ }
+ else if(0 != (as_range = try_member_cast<tn_range_base>(value)))
+ {
+ if(typeid(int) == as_range->value_type())
+ return get_impl<renderer_int_range_convertor>();
+ else if(typeid(double) == as_range->value_type())
+ return get_impl<renderer_double_range_convertor>();
+ else if(typeid(calendar_date) == as_range->value_type())
+ return get_impl<renderer_date_convertor>();
+ // else: fall through
+ }
+
+ return get_impl<renderer_fallback_convertor>();
+}
Even there the as_enum and as_sequence variables were useless — and I didn’t
catch it, probably because some earlier version of the patch did use them
similarly to how the as_range branch does. The cast served a purpose there,
testing if ‘value’ is of the given type, but the current version of the code
does it differently now.
In short: I too think it’s dead code that was accidentally left in.
Regards,
Vaclav