Cleanup: Pass std::string as const reference from media/
Passing std::string by reference can prevent extra copying of object. BUG=367418 TEST= R=dalecurtis@chromium.org,jrummell@chromium.org,sandersd@chromium.org Review URL: https://codereview.chromium.org/1360523002 Cr-Commit-Position: refs/heads/master@{#350046}
This commit is contained in:
media
@ -28,7 +28,7 @@ static const char kVidPathTemplate[] =
|
||||
static const char kPidPathTemplate[] =
|
||||
"/sys/class/video4linux/%s/device/../idProduct";
|
||||
|
||||
static bool ReadIdFile(const std::string path, std::string* id) {
|
||||
static bool ReadIdFile(const std::string& path, std::string* id) {
|
||||
char id_buf[kVidPidSize];
|
||||
FILE* file = fopen(path.c_str(), "rb");
|
||||
if (!file)
|
||||
|
@ -41,8 +41,8 @@ TransportEncryptionHandler::TransportEncryptionHandler()
|
||||
|
||||
TransportEncryptionHandler::~TransportEncryptionHandler() {}
|
||||
|
||||
bool TransportEncryptionHandler::Initialize(std::string aes_key,
|
||||
std::string aes_iv_mask) {
|
||||
bool TransportEncryptionHandler::Initialize(const std::string& aes_key,
|
||||
const std::string& aes_iv_mask) {
|
||||
is_activated_ = false;
|
||||
if (aes_iv_mask.size() == kAesKeySize && aes_key.size() == kAesKeySize) {
|
||||
iv_mask_ = aes_iv_mask;
|
||||
|
@ -26,7 +26,7 @@ class TransportEncryptionHandler : public base::NonThreadSafe {
|
||||
TransportEncryptionHandler();
|
||||
~TransportEncryptionHandler();
|
||||
|
||||
bool Initialize(std::string aes_key, std::string aes_iv_mask);
|
||||
bool Initialize(const std::string& aes_key, const std::string& aes_iv_mask);
|
||||
|
||||
bool Encrypt(uint32 frame_id,
|
||||
const base::StringPiece& data,
|
||||
|
@ -82,7 +82,7 @@ static const int kTargetPlayoutDelayMs = 100;
|
||||
// receiver.
|
||||
static const int kMaxAllowedPlayoutErrorMs = 30;
|
||||
|
||||
std::string ConvertFromBase16String(const std::string base_16) {
|
||||
std::string ConvertFromBase16String(const std::string& base_16) {
|
||||
std::string compressed;
|
||||
DCHECK_EQ(base_16.size() % 2, 0u) << "Must be a multiple of 2";
|
||||
compressed.reserve(base_16.size() / 2);
|
||||
|
@ -75,7 +75,7 @@ void GetPorts(uint16* tx_port, uint16* rx_port) {
|
||||
*rx_port = static_cast<uint16>(rx_input.GetIntInput());
|
||||
}
|
||||
|
||||
std::string GetIpAddress(const std::string display_text) {
|
||||
std::string GetIpAddress(const std::string& display_text) {
|
||||
test::InputBuilder input(display_text, DEFAULT_SEND_IP, INT_MIN, INT_MAX);
|
||||
std::string ip_address = input.GetStringInput();
|
||||
// Ensure IP address is either the default value or in correct form.
|
||||
|
@ -107,7 +107,7 @@ void QuitLoopOnInitializationResult(media::cast::OperationalStatus result) {
|
||||
base::MessageLoop::current()->Quit();
|
||||
}
|
||||
|
||||
net::IPEndPoint CreateUDPAddress(std::string ip_str, uint16 port) {
|
||||
net::IPEndPoint CreateUDPAddress(const std::string& ip_str, uint16 port) {
|
||||
net::IPAddressNumber ip_number;
|
||||
CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number));
|
||||
return net::IPEndPoint(ip_number, port);
|
||||
|
@ -63,7 +63,7 @@ int InputBuilder::GetIntInput() const {
|
||||
return int_value;
|
||||
}
|
||||
|
||||
bool InputBuilder::ValidateInput(const std::string input) const {
|
||||
bool InputBuilder::ValidateInput(const std::string& input) const {
|
||||
// Check for a valid range.
|
||||
if (low_range_ == INT_MIN && high_range_ == INT_MAX)
|
||||
return true;
|
||||
|
@ -33,7 +33,7 @@ class InputBuilder {
|
||||
int GetIntInput() const;
|
||||
|
||||
private:
|
||||
bool ValidateInput(const std::string input) const;
|
||||
bool ValidateInput(const std::string& input) const;
|
||||
|
||||
const std::string title_;
|
||||
const std::string default_value_;
|
||||
|
Reference in New Issue
Block a user