Optimized the checkRow() function.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2418 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index dfddbee..32f6147 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -268,17 +268,26 @@
   char *ptr_new = m_rowImage->xim->data;
 
   // Compare pixels, raise corresponding elements of m_changeFlags[].
+  // First, handle full-size (32 pixels wide) tiles.
   int nTilesChanged = 0;
-  for (int i = 0; i < w; i += 32) {
-    int tile_w = (w - i >= 32) ? 32 : w - i;
-    int nBytes = tile_w * m_bytesPerPixel;
-    if (memcmp(ptr_old, ptr_new, nBytes)) {
+  int nBytesPerTile = 32 * m_bytesPerPixel;
+  for (int i = 0; i < w / 32; i++) {
+    if (memcmp(ptr_old, ptr_new, nBytesPerTile)) {
       *pChangeFlags = true;
       nTilesChanged++;
     }
     pChangeFlags++;
-    ptr_old += nBytes;
-    ptr_new += nBytes;
+    ptr_old += nBytesPerTile;
+    ptr_new += nBytesPerTile;
+  }
+
+  // Handle the rightmost pixels, if the width is not a multiple of 32.
+  int nBytesLeft = (w % 32) * m_bytesPerPixel;
+  if (nBytesLeft != 0) {
+    if (memcmp(ptr_old, ptr_new, nBytesLeft)) {
+      *pChangeFlags = true;
+      nTilesChanged++;
+    }
   }
 
   return nTilesChanged;