Commit 21329c4c authored by Mark Santaniello's avatar Mark Santaniello Committed by Facebook GitHub Bot

Avoid copying ByteRange in OpenSSLHash hash_update()

Summary: This opportunity was found with the combination of Infer's PULSE_UNNECESSARY_COPY and Strobelight cycle counts.

Reviewed By: Gownta

Differential Revision: D33304127

fbshipit-source-id: 7d3b54d26bc3e171cc7a0a831933fdbb9638f6a8
parent 73242d19
...@@ -68,7 +68,7 @@ class OpenSSLHash { ...@@ -68,7 +68,7 @@ class OpenSSLHash {
md_ = md; md_ = md;
} }
void hash_update(ByteRange data) { void hash_update(const ByteRange& data) {
if (nullptr == ctx_) { if (nullptr == ctx_) {
throw_exception<std::runtime_error>( throw_exception<std::runtime_error>(
"hash_update() called without hash_init()"); "hash_update() called without hash_init()");
...@@ -78,7 +78,7 @@ class OpenSSLHash { ...@@ -78,7 +78,7 @@ class OpenSSLHash {
} }
void hash_update(const IOBuf& data) { void hash_update(const IOBuf& data) {
for (auto r : data) { for (const auto& r : data) {
hash_update(r); hash_update(r);
} }
} }
...@@ -196,7 +196,7 @@ class OpenSSLHash { ...@@ -196,7 +196,7 @@ class OpenSSLHash {
md_ = md; md_ = md;
} }
void hash_update(ByteRange data) { void hash_update(const ByteRange& data) {
if (ctx_ == nullptr) { if (ctx_ == nullptr) {
throw_exception<std::runtime_error>( throw_exception<std::runtime_error>(
"hash_update() called without hash_init()"); "hash_update() called without hash_init()");
...@@ -205,7 +205,7 @@ class OpenSSLHash { ...@@ -205,7 +205,7 @@ class OpenSSLHash {
} }
void hash_update(const IOBuf& data) { void hash_update(const IOBuf& data) {
for (auto r : data) { for (const auto& r : data) {
hash_update(r); hash_update(r);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment