summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergiu Deitsch <sergiud@users.noreply.github.com>2017-11-04 15:22:21 (GMT)
committerGitHub <noreply@github.com>2017-11-04 15:22:21 (GMT)
commitbac8811710c77ac3718be1c4801f43d37c1aea46 (patch)
tree362cd1d56a18356165ca6906ff801fecd93b02cb /src
parentd72e3be82c832601e1d8f6fba580d2edf8be13da (diff)
parent4544e968abe7ced002713650c02d909672a8aa4c (diff)
downloadglog-bac8811710c77ac3718be1c4801f43d37c1aea46.zip
glog-bac8811710c77ac3718be1c4801f43d37c1aea46.tar.gz
glog-bac8811710c77ac3718be1c4801f43d37c1aea46.tar.bz2
Merge pull request #106 from dimhotepus/master
Cache strlen outside of cycles (PVS-Studio)
Diffstat (limited to 'src')
-rw-r--r--src/logging_unittest.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc
index b8a9a87..59e9155 100644
--- a/src/logging_unittest.cc
+++ b/src/logging_unittest.cc
@@ -775,17 +775,18 @@ static void TestOneTruncate(const char *path, int64 limit, int64 keep,
CHECK_ERR(fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600));
const char *discardstr = "DISCARDME!", *keepstr = "KEEPME!";
+ const size_t discard_size = strlen(discardstr), keep_size = strlen(keepstr);
// Fill the file with the requested data; first discard data, then kept data
int64 written = 0;
while (written < dsize) {
- int bytes = min<int64>(dsize - written, strlen(discardstr));
+ int bytes = min<int64>(dsize - written, discard_size);
CHECK_ERR(write(fd, discardstr, bytes));
written += bytes;
}
written = 0;
while (written < ksize) {
- int bytes = min<int64>(ksize - written, strlen(keepstr));
+ int bytes = min<int64>(ksize - written, keep_size);
CHECK_ERR(write(fd, keepstr, bytes));
written += bytes;
}
@@ -807,7 +808,7 @@ static void TestOneTruncate(const char *path, int64 limit, int64 keep,
const char *p = buf;
int64 checked = 0;
while (checked < expect) {
- int bytes = min<int64>(expect - checked, strlen(keepstr));
+ int bytes = min<int64>(expect - checked, keep_size);
CHECK(!memcmp(p, keepstr, bytes));
checked += bytes;
}