From 04aa5201edfcd4b0716ade1e284872ff8069735b Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Fri, 18 Jan 2008 15:37:15 +0000 Subject: [PATCH] Minor code enhancement: using an inline function instead of inline arithmetic. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2412 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/x0vncserver/PollingManager.cxx | 9 ++++----- unix/x0vncserver/PollingManager.h | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index 0c35c400..b3934a25 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -257,10 +257,6 @@ int PollingManager::checkRow(int x, int y, int w) w += correction; } - // Compute a pointer to the corresponding element of m_changeFlags. - // FIXME: Provide an inline function for that? - bool *pChangeFlags = &m_changeFlags[(y / 32) * m_widthTiles + (x / 32)]; - // Read a row from the screen. Note that getFullRow() may be more // efficient than getRow() which is more general. // FIXME: Move the logic to getRow()? @@ -270,7 +266,10 @@ int PollingManager::checkRow(int x, int y, int w) getRow(x, y, w); } - // Compute pointers to images to be compared. + // Compute a pointer to the initial element of m_changeFlags. + bool *pChangeFlags = &m_changeFlags[getTileIndex(x, y)]; + + // Compute pointers to image data to be compared. char *ptr_old = m_image->locatePixel(x, y); char *ptr_new = m_rowImage->xim->data; diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h index 9f3ff883..e54494e6 100644 --- a/unix/x0vncserver/PollingManager.h +++ b/unix/x0vncserver/PollingManager.h @@ -97,6 +97,12 @@ private: m_offsetLeft + x, m_offsetTop + y, 1, h); } + inline int getTileIndex(int x, int y) { + int tile_x = x / 32; + int tile_y = y / 32; + return tile_y * m_widthTiles + tile_x; + } + int checkRow(int x, int y, int w); int checkColumn(int x, int y, int h, bool *pChangeFlags); int sendChanges(); -- 2.39.5