Change base::HexStringToBytes to take a StringPiece
This function is sometimes called with a base::StringPiece by first
converting it to an std::string. This is inefficent since it performs an
unnecessary copy. The signature has been updated and all the callsites
I could find where as_string() is called on a base::StringPiece have
been changed.
Change-Id: I1f9c674d61fe9f9835e89e40e7de0224b709ac57
Reviewed-on: https://chromium-review.googlesource.com/847852
Reviewed-by: Joshua Pawlicki <[email protected]>
Reviewed-by: Bence Béky <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#526829}
diff --git a/components/client_update_protocol/ecdsa.cc b/components/client_update_protocol/ecdsa.cc
index 38faa9ab..1af829b7 100644
--- a/components/client_update_protocol/ecdsa.cc
+++ b/components/client_update_protocol/ecdsa.cc
@@ -68,13 +68,13 @@
// the SignatureValidator class will handle the actual DER decoding and
// ASN.1 parsing. Check for an expected size range only -- valid ECDSA
// signatures are between 8 and 72 bytes.
- if (!base::HexStringToBytes(sig_hex.as_string(), ecdsa_signature_out))
+ if (!base::HexStringToBytes(sig_hex, ecdsa_signature_out))
return false;
if (ecdsa_signature_out->size() < 8 || ecdsa_signature_out->size() > 72)
return false;
// Decode the SHA-256 hash; it should be exactly 32 bytes, no more or less.
- if (!base::HexStringToBytes(hash_hex.as_string(), request_hash_out))
+ if (!base::HexStringToBytes(hash_hex, request_hash_out))
return false;
if (request_hash_out->size() != crypto::kSHA256Length)
return false;