[quagga-dev 7806] Re: [PATCH 2/2] Optimizaion of utility functions returning address family and sub-address family from current node.

Balaji G balajig81 at gmail.com
Mon Feb 22 04:42:44 GMT 2010


Hi Alexis

Yes i agree i shouldn't have used the word "optimization" here but rather
some kind of small cleanup rather having few if else statements but i guess
this does not do any harm either :)

Thanks for your feedback.

Cheers,
  - Balaji

On Mon, Feb 22, 2010 at 9:05 AM, Alexis Rosen <
quagga-users at alexis.users.panix.com> wrote:

> I don't think that this is in any way an optimization. The compiler should
> treat the patched and unpatched code identically, and from a readability
> perspective, the patch seems like a step back.
>
> But even if not, the alignment of parens in both patch hunks is off (again,
> from a readability perspective).
>
> /a
>
>
> On Feb 21, 2010, at 6:15 AM, Balaji G wrote:
>
>  ---
>> bgpd/bgp_vty.c |   13 +++++--------
>> 1 files changed, 5 insertions(+), 8 deletions(-)
>>
>> diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
>> index eb9ec9a..0734a58 100644
>> --- a/bgpd/bgp_vty.c
>> +++ b/bgpd/bgp_vty.c
>> @@ -55,9 +55,8 @@ extern struct in_addr router_id_zebra;
>> afi_t
>> bgp_node_afi (struct vty *vty)
>> {
>> -  if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
>> -    return AFI_IP6;
>> -  return AFI_IP;
>> +  return (((vty->node == BGP_IPV6_NODE)
>> +       || (vty->node == BGP_IPV6M_NODE)) ? AFI_IP6 : AFI_IP);
>> }
>>
>> /* Utility function to get subsequent address family from current
>> @@ -65,11 +64,9 @@ bgp_node_afi (struct vty *vty)
>> safi_t
>> bgp_node_safi (struct vty *vty)
>> {
>> -  if (vty->node == BGP_VPNV4_NODE)
>> -    return SAFI_MPLS_VPN;
>> -  if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
>> -    return SAFI_MULTICAST;
>> -  return SAFI_UNICAST;
>> +  return (((vty->node == BGP_VPNV4_NODE) ? SAFI_MPLS_VPN :
>> +            ((vty->node == BGP_IPV4M_NODE) || vty->node ==
>> BGP_IPV6M_NODE)
>> +            ? SAFI_MULTICAST : SAFI_UNICAST));
>> }
>>
>> static int
>> --
>> 1.6.6
>>
>> _______________________________________________
>> Quagga-dev mailing list
>> Quagga-dev at lists.quagga.net
>> http://lists.quagga.net/mailman/listinfo/quagga-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20100222/ebe77a09/attachment-0001.html>


More information about the Quagga-dev mailing list