* Use const reference type for parameters and
for-loop index variables to avoid unnecessary copy.
Bug:
30407689
Bug:
30413223
Change-Id: Ie99f89ee67de9f2ace61f0971cd4a1820617f7d4
Test: build with WITH_TIDY=1
return Status::ok();
}
-bool AudioServiceCallback::Equals(android::sp<AudioServiceCallback> callback) {
+bool AudioServiceCallback::Equals(const android::sp<AudioServiceCallback>& callback) {
if (callback->connected_callback_.Equals(connected_callback_) &&
callback->disconnected_callback_.Equals(disconnected_callback_) &&
callback->volume_callback_.Equals(volume_callback_) &&
// compared with this.
//
// Returns true if |callback| equals this.
- bool Equals(android::sp<AudioServiceCallback> callback);
+ bool Equals(const android::sp<AudioServiceCallback>& callback);
private:
// Callback when devices are connected.
}
android::sp<android::IBinder> BrilloAudioClient::ConnectToService(
- std::string service_name, const base::Closure& callback) {
+ const std::string& service_name, const base::Closure& callback) {
android::BinderWrapper* binder_wrapper =
android::BinderWrapper::GetOrCreateInstance();
auto service = binder_wrapper->GetService(service_name);
//
// |service_name| is a string representing the name of the service.
// |callback| is a base::Closure which will be called if the service dies.
- android::sp<android::IBinder> ConnectToService(std::string service_name,
+ android::sp<android::IBinder> ConnectToService(const std::string& service_name,
const base::Closure& callback);
// Pointer to the BrilloAudioClient object.
void BrilloAudioServiceImpl::OnDevicesConnected(
const std::vector<int>& devices) {
- for (auto callback : callbacks_set_) {
+ for (const auto& callback : callbacks_set_) {
callback->OnAudioDevicesConnected(devices);
}
}
void BrilloAudioServiceImpl::OnDevicesDisconnected(
const std::vector<int>& devices) {
- for (auto callback : callbacks_set_) {
+ for (const auto& callback : callbacks_set_) {
callback->OnAudioDevicesDisconnected(devices);
}
}
void BrilloAudioServiceImpl::OnVolumeChanged(audio_stream_type_t stream,
int previous_index,
int current_index) {
- for (auto callback : callbacks_set_) {
+ for (const auto& callback : callbacks_set_) {
callback->OnVolumeChanged(stream, previous_index, current_index);
}
}