Index: trunk/Mars/mcore/checksum.h
===================================================================
--- trunk/Mars/mcore/checksum.h	(revision 16541)
+++ trunk/Mars/mcore/checksum.h	(revision 16546)
@@ -1,4 +1,6 @@
 #ifndef MARS_checksum
 #define MARS_checksum
+
+#include <arpa/inet.h>
 
 namespace std
@@ -65,14 +67,30 @@
         }
 
-        const unsigned short *sbuf = reinterpret_cast<const unsigned short *>(buf);
+        const uint32_t *sbuf = reinterpret_cast<const uint32_t*>(buf);
 
         uint32_t *hilo  = reinterpret_cast<uint32_t*>(&buffer);
 
+        /*
         for (size_t i = 0; i < len/2; i++)
         {
             //swap the bytes of the 32 bits value. but...
             //the hi and lo values are stored in fits-like order. do not swap them
-            hilo[i%2] += (sbuf[i]&0xff00)>>8 | (sbuf[i]&0x00ff)<<8;
-        }
+            hilo[i%2] += ntohs(sbuf[i]); //(sbuf[i]&0xff00)>>8 | (sbuf[i]&0x00ff)<<8;
+        }*/
+
+        // This is about as twice as fast as the loop above
+        // ntohs is CPU optimized, hilo[n] doesn't need to be computed
+        const uint32_t *end = sbuf + len/2;
+        while (1)
+        {
+            hilo[0] += ntohs(*sbuf++);
+            if (sbuf==end)
+                break;
+
+            hilo[1] += ntohs(*sbuf++);
+            if (sbuf==end)
+                break;
+        }
+
         HandleCarryBits();
 
