From 40e17afbceaa325776356fd4cd7cc2805cd054c2 Mon Sep 17 00:00:00 2001 From: svost Date: Mon, 15 Feb 2016 21:52:07 +0300 Subject: [PATCH] Move the constant variable outside the loop --- src/db.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 6dde84e..81d519a 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -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(); -- 1.7.1