[TCP] Avoid two divides in tcp_output.c
authorEric Dumazet <dada1@cosmosbay.com>
Fri, 21 Dec 2007 05:48:32 +0000 (21:48 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:59:41 +0000 (14:59 -0800)
Because 'free_space' variable in __tcp_select_window() is signed,
expression (free_space / 2) forces compiler to emit an integer divide.

This can be changed to a plain right shift, less expensive.

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

index 7c50271ddc30e05aabc6908d1ebb56fa5d40a22a..9a9510acb147ff555320e7b460612708a00dcad1 100644 (file)
@@ -1627,7 +1627,7 @@ u32 __tcp_select_window(struct sock *sk)
        if (mss > full_space)
                mss = full_space;
 
-       if (free_space < full_space/2) {
+       if (free_space < (full_space >> 1)) {
                icsk->icsk_ack.quick = 0;
 
                if (tcp_memory_pressure)
@@ -1666,7 +1666,7 @@ u32 __tcp_select_window(struct sock *sk)
                if (window <= free_space - mss || window > free_space)
                        window = (free_space/mss)*mss;
                else if (mss == full_space &&
-                        free_space > window + full_space/2)
+                        free_space > window + (full_space >> 1))
                        window = free_space;
        }