]> err.no Git - linux-2.6/commitdiff
[TCP]: Avoid two divides in __tcp_grow_window()
authorEric Dumazet <dada1@cosmosbay.com>
Fri, 21 Dec 2007 14:07:53 +0000 (06:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:00:01 +0000 (15:00 -0800)
tcp_win_from_space() being signed, compiler might emit an integer divide
to compute tcp_win_from_space()/2 .

Using right shifts is OK here and less expensive.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_input.c

index bc2d5f70966eb19ccdf71466fef08c81ddbf503d..519bd24e0d3b7ba598101d1c20ff903b40e597ae 100644 (file)
@@ -289,8 +289,8 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        /* Optimize this! */
-       int truesize = tcp_win_from_space(skb->truesize)/2;
-       int window = tcp_win_from_space(sysctl_tcp_rmem[2])/2;
+       int truesize = tcp_win_from_space(skb->truesize) >> 1;
+       int window = tcp_win_from_space(sysctl_tcp_rmem[2]) >> 1;
 
        while (tp->rcv_ssthresh <= window) {
                if (truesize <= skb->len)