[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20071231.044759.141743569.davem@davemloft.net>
Date: Mon, 31 Dec 2007 04:47:59 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: ilpo.jarvinen@...sinki.fi
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH 3/9] [TCP]: Remove unnecessary local variables
From: "Ilpo_Järvinen" <ilpo.jarvinen@...sinki.fi>
Date: Mon, 31 Dec 2007 12:47:51 +0200
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...sinki.fi>
...
>
> - in_flight = tcp_packets_in_flight(tp);
> - cwnd = tp->snd_cwnd;
> - if (in_flight < cwnd)
> - return (cwnd - in_flight);
> + if (tcp_packets_in_flight(tp) < tp->snd_cwnd)
> + return tp->snd_cwnd - tcp_packets_in_flight(tp);
>
I don't know about this one.
Although tcp_packets_in_flight() is inline and the compiler
should CSE the first call into a local register and not
redo the calculation:
1) That isn't something to rely upon. The compiler might look
at a function or set of functions in this file and decide
to not inline tcp_packets_in_flight() or not see the CSE
opportunity and that the second call is redundant.
2) If we stop inlining tcp_packets_in_flight() then nobody, and I
mean nobody, is going to remember to come back here and
add back the code to put the result in a local variable.
So best to keep the local vars here.
I also think the code is clearer that way too.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists