Commit 6c5248f9 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Micro-optimise seqno computation.

parent d8e74ded
...@@ -40,21 +40,14 @@ seqno_compare(unsigned short s1, unsigned short s2) ...@@ -40,21 +40,14 @@ seqno_compare(unsigned short s1, unsigned short s2)
{ {
if(s1 == s2) if(s1 == s2)
return 0; return 0;
else if(((s2 - s1) & 0xFFFF) < 0x8000)
return -1;
else else
return 1; return ((s2 - s1) & 0x8000) ? 1 : -1;
} }
int int
seqno_minus(unsigned short s1, unsigned short s2) seqno_minus(unsigned short s1, unsigned short s2)
{ {
if(s1 == s2) return ((s1 - s2) & 0xFFFF);
return 0;
else if(((s2 - s1) & 0xFFFF) < 0x8000)
return -(int)((s2 - s1) & 0xFFFF);
else
return ((s1 - s2) & 0xFFFF);
} }
unsigned short unsigned short
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment