Skip to content

Commit 8714bed

Browse files
Googlera-maurice
authored andcommitted
Migrate const std::string& parameters to absl::string_view.
THIS CHANGE IS BELIEVED SAFE Templated asynchronous code can change the lifetime of string data as a result of this change; however, the most common uses of these (lambdas and callbacks) are excluded from this change. Further, your TAP tests pass. go/string-ref-to-string-view-lsc Tested: TAP --sample ran all affected tests and none failed http://test/OCL:319219698:BASE:319213711:1593616691507:a583f044 PiperOrigin-RevId: 319286243
1 parent 6815e02 commit 8714bed

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/rest/tests/zlibwrapper_unittest.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "gmock/gmock.h"
2828
#include "absl/base/macros.h"
2929
#include "absl/strings/escaping.h"
30+
#include "absl/strings/string_view.h"
3031
#include "util/random/acmrandom.h"
3132

3233
// 1048576 == 2^20 == 1 MB
@@ -105,7 +106,7 @@ REGISTER_MODULE_INITIALIZER(zlibwrapper_unittest, {
105106
<< " Reason: " << limiter.reason();
106107
});
107108

108-
bool ReadFileToString(const std::string& filename, std::string* output,
109+
bool ReadFileToString(absl::string_view filename, std::string* output,
109110
int64 max_size) {
110111
std::ifstream f;
111112
f.open(filename);
@@ -696,7 +697,7 @@ class ZLibWrapperTest : public ::testing::TestWithParam<std::string> {
696697
return dict;
697698
}
698699

699-
std::string ReadFileToTest(const std::string& filename) {
700+
std::string ReadFileToTest(absl::string_view filename) {
700701
std::string uncompbuf;
701702
LOG(INFO) << "Testing file: " << filename;
702703
CHECK(ReadFileToString(filename, &uncompbuf, MAX_BUF_SIZE));

app/tests/base64_openssh_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "app/src/log.h"
1919
#include "gtest/gtest.h"
2020
#include "gmock/gmock.h"
21+
#include "absl/strings/string_view.h"
2122
#include "openssl/base64.h"
2223

2324
namespace firebase {
@@ -31,7 +32,7 @@ size_t OpenSSHEncodedLength(size_t input_size) {
3132
return length;
3233
}
3334

34-
bool OpenSSHEncode(const std::string& input, std::string* output) {
35+
bool OpenSSHEncode(absl::string_view input, std::string* output) {
3536
size_t base64_length = OpenSSHEncodedLength(input.size());
3637
output->resize(base64_length);
3738
if (EVP_EncodeBlock(reinterpret_cast<uint8_t*>(&(*output)[0]),
@@ -52,7 +53,7 @@ size_t OpenSSHDecodedLength(size_t input_size) {
5253
return length;
5354
}
5455

55-
bool OpenSSHDecode(const std::string& input, std::string* output) {
56+
bool OpenSSHDecode(absl::string_view input, std::string* output) {
5657
size_t decoded_length = OpenSSHDecodedLength(input.size());
5758
output->resize(decoded_length);
5859
if (EVP_DecodeBase64(reinterpret_cast<uint8_t*>(&(*output)[0]),

0 commit comments

Comments
 (0)