Skip to content

Commit 62363d9

Browse files
committed
Fully qualify std::string.
This is in preparation for removing the snappy::string alias of std::string. PiperOrigin-RevId: 271383199
1 parent d837d5c commit 62363d9

File tree

8 files changed

+119
-118
lines changed

8 files changed

+119
-118
lines changed
File renamed without changes.

snappy-stubs-internal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace snappy {
3535

36-
void Varint::Append32(string* s, uint32 value) {
36+
void Varint::Append32(std::string* s, uint32 value) {
3737
char buf[Varint::kMax32];
3838
const char* p = Varint::Encode32(buf, value);
3939
s->append(buf, p - buf);

snappy-stubs-internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class Varint {
524524
static char* Encode32(char* ptr, uint32 v);
525525

526526
// EFFECTS Appends the varint representation of "value" to "*s".
527-
static void Append32(string* s, uint32 value);
527+
static void Append32(std::string* s, uint32 value);
528528
};
529529

530530
inline const char* Varint::Parse32WithLimit(const char* p,
@@ -581,7 +581,7 @@ inline char* Varint::Encode32(char* sptr, uint32 v) {
581581
// replace this function with one that resizes the string without
582582
// filling the new space with zeros (if applicable) --
583583
// it will be non-portable but faster.
584-
inline void STLStringResizeUninitialized(string* s, size_t new_size) {
584+
inline void STLStringResizeUninitialized(std::string* s, size_t new_size) {
585585
s->resize(new_size);
586586
}
587587

@@ -597,7 +597,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) {
597597
// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530)
598598
// proposes this as the method. It will officially be part of the standard
599599
// for C++0x. This should already work on all current implementations.
600-
inline char* string_as_array(string* str) {
600+
inline char* string_as_array(std::string* str) {
601601
return str->empty() ? NULL : &*str->begin();
602602
}
603603

snappy-test.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ DEFINE_bool(run_microbenchmarks, true,
4848

4949
namespace snappy {
5050

51-
string ReadTestDataFile(const string& base, size_t size_limit) {
52-
string contents;
51+
std::string ReadTestDataFile(const std::string& base, size_t size_limit) {
52+
std::string contents;
5353
const char* srcdir = getenv("srcdir"); // This is set by Automake.
54-
string prefix;
54+
std::string prefix;
5555
if (srcdir) {
56-
prefix = string(srcdir) + "/";
56+
prefix = std::string(srcdir) + "/";
5757
}
5858
file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults()
5959
).CheckSuccess();
@@ -63,11 +63,11 @@ string ReadTestDataFile(const string& base, size_t size_limit) {
6363
return contents;
6464
}
6565

66-
string ReadTestDataFile(const string& base) {
66+
std::string ReadTestDataFile(const std::string& base) {
6767
return ReadTestDataFile(base, 0);
6868
}
6969

70-
string StringPrintf(const char* format, ...) {
70+
std::string StringPrintf(const char* format, ...) {
7171
char buf[4096];
7272
va_list ap;
7373
va_start(ap, format);
@@ -79,7 +79,7 @@ string StringPrintf(const char* format, ...) {
7979
bool benchmark_running = false;
8080
int64 benchmark_real_time_us = 0;
8181
int64 benchmark_cpu_time_us = 0;
82-
string *benchmark_label = NULL;
82+
std::string* benchmark_label = nullptr;
8383
int64 benchmark_bytes_processed = 0;
8484

8585
void ResetBenchmarkTiming() {
@@ -163,11 +163,11 @@ void StopBenchmarkTiming() {
163163
benchmark_running = false;
164164
}
165165

166-
void SetBenchmarkLabel(const string& str) {
166+
void SetBenchmarkLabel(const std::string& str) {
167167
if (benchmark_label) {
168168
delete benchmark_label;
169169
}
170-
benchmark_label = new string(str);
170+
benchmark_label = new std::string(str);
171171
}
172172

173173
void SetBenchmarkBytesProcessed(int64 bytes) {
@@ -217,8 +217,8 @@ void Benchmark::Run() {
217217
benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us;
218218
}
219219

220-
string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num);
221-
string human_readable_speed;
220+
std::string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num);
221+
std::string human_readable_speed;
222222

223223
std::nth_element(benchmark_runs,
224224
benchmark_runs + kMedianPos,

snappy-test.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace file {
167167
namespace snappy {
168168

169169
#define FLAGS_test_random_seed 301
170-
typedef string TypeParam;
170+
using TypeParam = std::string;
171171

172172
void Test_CorruptedTest_VerifyCorrupted();
173173
void Test_Snappy_SimpleTests();
@@ -181,13 +181,13 @@ void Test_Snappy_ReadPastEndOfBuffer();
181181
void Test_Snappy_FindMatchLength();
182182
void Test_Snappy_FindMatchLengthRandom();
183183

184-
string ReadTestDataFile(const string& base, size_t size_limit);
184+
std::string ReadTestDataFile(const std::string& base, size_t size_limit);
185185

186-
string ReadTestDataFile(const string& base);
186+
std::string ReadTestDataFile(const std::string& base);
187187

188188
// A sprintf() variant that returns a std::string.
189189
// Not safe for general use due to truncation issues.
190-
string StringPrintf(const char* format, ...);
190+
std::string StringPrintf(const char* format, ...);
191191

192192
// A wall-time clock. This stub is not super-accurate, nor resistant to the
193193
// system time changing.
@@ -241,8 +241,8 @@ typedef void (*BenchmarkFunction)(int, int);
241241

242242
class Benchmark {
243243
public:
244-
Benchmark(const string& name, BenchmarkFunction function) :
245-
name_(name), function_(function) {}
244+
Benchmark(const std::string& name, BenchmarkFunction function)
245+
: name_(name), function_(function) {}
246246

247247
Benchmark* DenseRange(int start, int stop) {
248248
start_ = start;
@@ -253,7 +253,7 @@ class Benchmark {
253253
void Run();
254254

255255
private:
256-
const string name_;
256+
const std::string name_;
257257
const BenchmarkFunction function_;
258258
int start_, stop_;
259259
};
@@ -271,7 +271,7 @@ extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize;
271271
void ResetBenchmarkTiming();
272272
void StartBenchmarkTiming();
273273
void StopBenchmarkTiming();
274-
void SetBenchmarkLabel(const string& str);
274+
void SetBenchmarkLabel(const std::string& str);
275275
void SetBenchmarkBytesProcessed(int64 bytes);
276276

277277
#ifdef HAVE_LIBZ

snappy.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ bool RawUncompress(Source* compressed, char* uncompressed) {
13461346
return InternalUncompress(compressed, &output);
13471347
}
13481348

1349-
bool Uncompress(const char* compressed, size_t n, string* uncompressed) {
1349+
bool Uncompress(const char* compressed, size_t n, std::string* uncompressed) {
13501350
size_t ulength;
13511351
if (!GetUncompressedLength(compressed, n, &ulength)) {
13521352
return false;
@@ -1414,7 +1414,8 @@ void RawCompress(const char* input,
14141414
*compressed_length = (writer.CurrentDestination() - compressed);
14151415
}
14161416

1417-
size_t Compress(const char* input, size_t input_length, string* compressed) {
1417+
size_t Compress(const char* input, size_t input_length,
1418+
std::string* compressed) {
14181419
// Pre-grow the buffer to the max length of the compressed output
14191420
STLStringResizeUninitialized(compressed, MaxCompressedLength(input_length));
14201421

snappy.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ namespace snappy {
6969
// Higher-level string based routines (should be sufficient for most users)
7070
// ------------------------------------------------------------------------
7171

72-
// Sets "*output" to the compressed version of "input[0,input_length-1]".
73-
// Original contents of *output are lost.
72+
// Sets "*compressed" to the compressed version of "input[0,input_length-1]".
73+
// Original contents of *compressed are lost.
7474
//
75-
// REQUIRES: "input[]" is not an alias of "*output".
76-
size_t Compress(const char* input, size_t input_length, string* output);
75+
// REQUIRES: "input[]" is not an alias of "*compressed".
76+
size_t Compress(const char* input, size_t input_length,
77+
std::string* compressed);
7778

7879
// Decompresses "compressed[0,compressed_length-1]" to "*uncompressed".
7980
// Original contents of "*uncompressed" are lost.
@@ -82,7 +83,7 @@ namespace snappy {
8283
//
8384
// returns false if the message is corrupted and could not be decompressed
8485
bool Uncompress(const char* compressed, size_t compressed_length,
85-
string* uncompressed);
86+
std::string* uncompressed);
8687

8788
// Decompresses "compressed" to "*uncompressed".
8889
//

0 commit comments

Comments
 (0)