aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2016-07-27 14:20:43 -0700
committerTreehugger Robot <treehugger-gerrit@google.com>2016-07-27 22:36:08 +0000
commit67cb971d4b7abdd2ddc82456a63199aaf99173f0 (patch)
tree253693a28e063189441d3480b8f3b9f00c91329a
parenta7054911b8cb65c65ddc4f3548ad6515a1f778f2 (diff)
downloadwebservd-67cb971d4b7abdd2ddc82456a63199aaf99173f0.tar.gz
Fix clang-tidy performance warnings in webservd.
* Use const reference type for parameters and for-loop index variables to avoid unnecessary copy. Bug: 30407689 Bug: 30413223 Change-Id: I7e9c4906ae3f48baefe860d5cd1e651d3095f2b6 Test: build with WITH_TIDY=1
-rw-r--r--libwebserv/binder_server.cc6
-rw-r--r--libwebserv/binder_server.h2
-rw-r--r--libwebserv/request_utils.cc4
-rw-r--r--webservd/binder_server.cc2
4 files changed, 7 insertions, 7 deletions
diff --git a/libwebserv/binder_server.cc b/libwebserv/binder_server.cc
index 3cce096..3018480 100644
--- a/libwebserv/binder_server.cc
+++ b/libwebserv/binder_server.cc
@@ -99,7 +99,7 @@ class BinderProtocolHandler : public ProtocolHandler {
ResetRemoteProtocolHandlers();
}
- bool AddRemote(sp<IProtocolHandler> handler) {
+ bool AddRemote(const sp<IProtocolHandler>& handler) {
string name;
int32_t port;
string protocol;
@@ -138,7 +138,7 @@ class BinderProtocolHandler : public ProtocolHandler {
unique_ptr<RequestHandlerRegistration> registration(
new RequestHandlerRegistration(url, method, std::move(handler)));
- for (sp<IProtocolHandler> remote : remote_handlers_) {
+ for (const sp<IProtocolHandler>& remote : remote_handlers_) {
registration->AddRemote(remote);
}
@@ -257,7 +257,7 @@ void BinderServer::ClearLocalState() {
remote_server_.clear();
}
-bool BinderServer::BuildLocalState(sp<IBinder> server) {
+bool BinderServer::BuildLocalState(const sp<IBinder>& server) {
remote_server_ = android::interface_cast<RemoteServer>(server);
vector<sp<IBinder>> remote_raw_binders;
if (!remote_server_->GetProtocolHandlers("", &remote_raw_binders).isOk()) {
diff --git a/libwebserv/binder_server.h b/libwebserv/binder_server.h
index 2e21cfe..98da60b 100644
--- a/libwebserv/binder_server.h
+++ b/libwebserv/binder_server.h
@@ -66,7 +66,7 @@ class LIBWEBSERV_PRIVATE BinderServer : public Server {
void TryConnecting();
void ClearLocalState();
- bool BuildLocalState(android::sp<android::IBinder> server);
+ bool BuildLocalState(const android::sp<android::IBinder>& server);
// Used to poll for webservd availability and notify the user of changes
brillo::MessageLoop* message_loop_;
diff --git a/libwebserv/request_utils.cc b/libwebserv/request_utils.cc
index 879f8b2..0c65025 100644
--- a/libwebserv/request_utils.cc
+++ b/libwebserv/request_utils.cc
@@ -32,7 +32,7 @@ struct RequestDataContainer {
std::vector<uint8_t> data;
};
-void OnCopySuccess(std::shared_ptr<RequestDataContainer> container,
+void OnCopySuccess(const std::shared_ptr<RequestDataContainer>& container,
brillo::StreamPtr /* in_stream */,
brillo::StreamPtr out_stream,
uint64_t /* size_copied */) {
@@ -44,7 +44,7 @@ void OnCopySuccess(std::shared_ptr<RequestDataContainer> container,
std::move(container->data));
}
-void OnCopyError(std::shared_ptr<RequestDataContainer> container,
+void OnCopyError(const std::shared_ptr<RequestDataContainer>& container,
brillo::StreamPtr /* in_stream */,
brillo::StreamPtr /* out_stream */,
const brillo::Error* error) {
diff --git a/webservd/binder_server.cc b/webservd/binder_server.cc
index bc588cb..ede4854 100644
--- a/webservd/binder_server.cc
+++ b/webservd/binder_server.cc
@@ -282,7 +282,7 @@ Status BinderServer::GetProtocolHandlers(
vector<sp<IBinder>>* result) {
result->clear();
- for (auto handler : protocol_handlers_) {
+ for (const auto& handler : protocol_handlers_) {
string handler_name;
if (name.empty()) {