Minor code refactoring: remembering the number of 32x32 tiles in a member variable.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2405 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index b058d5b..6625cb8 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -68,6 +68,7 @@
   // Compute width and height in 32x32 tiles.
   m_widthTiles = (m_width + 31) / 32;
   m_heightTiles = (m_height + 31) / 32;
+  m_numTiles = m_widthTiles * m_heightTiles;
 
   // Get initial screen image.
   m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop);
@@ -86,11 +87,10 @@
                primaryImgClass, rowImgClass, columnImgClass);
   }
 
-  int numTiles = m_widthTiles * m_heightTiles;
-  m_rateMatrix = new char[numTiles];
-  m_videoFlags = new char[numTiles];
-  memset(m_rateMatrix, 0, numTiles);
-  memset(m_videoFlags, 0, numTiles);
+  m_rateMatrix = new char[m_numTiles];
+  m_videoFlags = new char[m_numTiles];
+  memset(m_rateMatrix, 0, m_numTiles);
+  memset(m_videoFlags, 0, m_numTiles);
 }
 
 PollingManager::~PollingManager()
@@ -190,8 +190,8 @@
   // in that tile. Initially, we fill in the array with zero values.
   //
   // FIXME: Should we use a member variable in place of changeFlags?
-  bool *changeFlags = new bool[m_widthTiles * m_heightTiles];
-  memset(changeFlags, 0, m_widthTiles * m_heightTiles * sizeof(bool));
+  bool *changeFlags = new bool[m_numTiles];
+  memset(changeFlags, 0, m_numTiles * sizeof(bool));
 
   // First pass over the framebuffer. Here we scan 1/32 part of the
   // framebuffer -- that is, one line in each (32 * m_width) stripe.
@@ -347,15 +347,14 @@
 void PollingManager::handleVideo(const bool *pChangeFlags)
 {
   // Update counters in m_rateMatrix.
-  int numTiles = m_heightTiles * m_widthTiles;
-  for (int i = 0; i < numTiles; i++)
+  for (int i = 0; i < m_numTiles; i++)
     m_rateMatrix[i] += (pChangeFlags[i] != false);
 
   // Once per eight calls: detect video rectangle by examining
   // m_rateMatrix[], then reset counters in m_rateMatrix[].
   if (m_pollingStep % 8 == 0) {
     detectVideo();
-    memset(m_rateMatrix, 0, numTiles);
+    memset(m_rateMatrix, 0, m_numTiles);
   }
 }
 
@@ -466,20 +465,19 @@
   // In m_rateMatrix, clear counters corresponding to non-32x32 tiles.
   // This will guarantee that the size of the video area is always a
   // multiple of 32 pixels. This is important for hardware JPEG encoders.
-  int numTiles = m_heightTiles * m_widthTiles;
   if (m_width % 32 != 0) {
-    for (int n = m_widthTiles - 1; n < numTiles; n += m_widthTiles)
+    for (int n = m_widthTiles - 1; n < m_numTiles; n += m_widthTiles)
       m_rateMatrix[n] = 0;
   }
   if (m_height % 32 != 0) {
-    for (int n = numTiles - m_widthTiles; n < numTiles; n++)
+    for (int n = m_numTiles - m_widthTiles; n < m_numTiles; n++)
       m_rateMatrix[n] = 0;
   }
 
   // First, detect candidate region that looks like video. In other
   // words, find a region that consists of continuously changing
   // pixels. Save the result in m_videoFlags[].
-  for (int i = 0; i < numTiles; i++) {
+  for (int i = 0; i < m_numTiles; i++) {
     if (m_rateMatrix[i] <= VIDEO_THRESHOLD_0) {
       m_videoFlags[i] = 0;
     } else if (m_rateMatrix[i] >= VIDEO_THRESHOLD_1) {