Move the constant variable outside the loop
authorsvost <svost@users.noreply.github.com>
Mon, 15 Feb 2016 18:52:07 +0000 (21:52 +0300)
committersvost <svost@users.noreply.github.com>
Mon, 15 Feb 2016 18:52:07 +0000 (21:52 +0300)
src/db.cpp

index 6dde84e..81d519a 100644 (file)
@@ -396,7 +396,8 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
                     }
 
                     Dbc* pcursor = db.GetCursor();
-                    if (pcursor)
+                    if (pcursor) {
+                        size_t pszSkipLen = strlen(pszSkip);
                         while (fSuccess)
                         {
                             CDataStream ssKey(SER_DISK, CLIENT_VERSION);
@@ -414,7 +415,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
                                 break;
                             }
                             if (pszSkip &&
-                                strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
+                                strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), pszSkipLen)) == 0)
                                 continue;
                             if (strncmp(&ssKey[0], "\x07version", 8) == 0)
                             {
@@ -428,6 +429,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
                             if (ret2 > 0)
                                 fSuccess = false;
                         }
+                    }
                     if (fSuccess)
                     {
                         db.Close();