Skip to content

Commit

Permalink
adds std:: to stl types (google#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad Nouri authored and Alkis Evlogimenos committed Jan 26, 2017
1 parent 27c5d86 commit 818b583
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
23 changes: 12 additions & 11 deletions snappy-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ char* CompressFragment(const char* input,
// Separate implementation for x86_64, for speed. Uses the fact that
// x86_64 is little endian.
#if defined(ARCH_K8)
static inline pair<size_t, bool> FindMatchLength(const char* s1,
const char* s2,
const char* s2_limit) {
static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
const char* s2,
const char* s2_limit) {
assert(s2_limit >= s2);
size_t matched = 0;

Expand All @@ -98,7 +98,8 @@ static inline pair<size_t, bool> FindMatchLength(const char* s1,
uint64 a1 = UNALIGNED_LOAD64(s1);
uint64 a2 = UNALIGNED_LOAD64(s2);
if (a1 != a2) {
return pair<size_t, bool>(Bits::FindLSBSetNonZero64(a1 ^ a2) >> 3, true);
return std::pair<size_t, bool>(Bits::FindLSBSetNonZero64(a1 ^ a2) >> 3,
true);
} else {
matched = 8;
s2 += 8;
Expand All @@ -118,23 +119,23 @@ static inline pair<size_t, bool> FindMatchLength(const char* s1,
int matching_bits = Bits::FindLSBSetNonZero64(x);
matched += matching_bits >> 3;
assert(matched >= 8);
return pair<size_t, bool>(matched, false);
return std::pair<size_t, bool>(matched, false);
}
}
while (PREDICT_TRUE(s2 < s2_limit)) {
if (s1[matched] == *s2) {
++s2;
++matched;
} else {
return pair<size_t, bool>(matched, matched < 8);
return std::pair<size_t, bool>(matched, matched < 8);
}
}
return pair<size_t, bool>(matched, matched < 8);
return std::pair<size_t, bool>(matched, matched < 8);
}
#else
static inline pair<size_t, bool> FindMatchLength(const char* s1,
const char* s2,
const char* s2_limit) {
static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
const char* s2,
const char* s2_limit) {
// Implementation based on the x86-64 version, above.
assert(s2_limit >= s2);
int matched = 0;
Expand All @@ -154,7 +155,7 @@ static inline pair<size_t, bool> FindMatchLength(const char* s1,
++matched;
}
}
return pair<size_t, bool>(matched, matched < 8);
return std::pair<size_t, bool>(matched, matched < 8);
}
#endif

Expand Down
7 changes: 4 additions & 3 deletions snappy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ char* CompressFragment(const char* input,
// We have a 4-byte match at ip, and no need to emit any
// "literal bytes" prior to ip.
const char* base = ip;
pair<size_t, bool> p = FindMatchLength(candidate + 4, ip + 4, ip_end);
std::pair<size_t, bool> p =
FindMatchLength(candidate + 4, ip + 4, ip_end);
size_t matched = 4 + p.first;
ip += matched;
size_t offset = base - candidate;
Expand Down Expand Up @@ -1216,7 +1217,7 @@ class SnappyScatteredWriter {
// We need random access into the data generated so far. Therefore
// we keep track of all of the generated data as an array of blocks.
// All of the blocks except the last have length kBlockSize.
vector<char*> blocks_;
std::vector<char*> blocks_;
size_t expected_;

// Total size of all fully generated blocks so far
Expand Down Expand Up @@ -1399,7 +1400,7 @@ class SnappySinkAllocator {
}

Sink* dest_;
vector<Datablock> blocks_;
std::vector<Datablock> blocks_;

// Note: copying this object is allowed
};
Expand Down
11 changes: 6 additions & 5 deletions snappy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ static void Measure(const char* data,
{
// Chop the input into blocks
int num_blocks = (length + block_size - 1) / block_size;
vector<const char*> input(num_blocks);
vector<size_t> input_length(num_blocks);
vector<string> compressed(num_blocks);
vector<string> output(num_blocks);
std::vector<const char*> input(num_blocks);
std::vector<size_t> input_length(num_blocks);
std::vector<string> compressed(num_blocks);
std::vector<string> output(num_blocks);
for (int b = 0; b < num_blocks; b++) {
int input_start = b * block_size;
int input_limit = min<int>((b+1)*block_size, length);
Expand Down Expand Up @@ -1054,7 +1054,8 @@ TEST(Snappy, ZeroOffsetCopyValidation) {
namespace {

int TestFindMatchLength(const char* s1, const char *s2, unsigned length) {
pair<size_t, bool> p = snappy::internal::FindMatchLength(s1, s2, s2 + length);
std::pair<size_t, bool> p =
snappy::internal::FindMatchLength(s1, s2, s2 + length);
CHECK_EQ(p.first < 8, p.second);
return p.first;
}
Expand Down

0 comments on commit 818b583

Please sign in to comment.