Fix clang-tidy performance warnings in libhardware.
* Use const reference parameter type to avoid unnecessary copy.
Bug: 30407689
Change-Id: Ibf19e5529e548bba21fcc8403eb356cb49548172
Test: build with WITH_TIDY=1
diff --git a/tests/camera2/CameraMultiStreamTests.cpp b/tests/camera2/CameraMultiStreamTests.cpp
index eb64db1..f4aeab7 100644
--- a/tests/camera2/CameraMultiStreamTests.cpp
+++ b/tests/camera2/CameraMultiStreamTests.cpp
@@ -334,7 +334,7 @@
int height,
const sp<CameraDeviceBase>& device,
CameraStreamParams param = DEFAULT_STREAM_PARAMETERS,
- sp<Surface> surface = NULL,
+ const sp<Surface>& surface = NULL,
bool useCpuConsumer = true) {
param.mFormat = MapAutoFormat(param.mFormat);
return new CameraStream(width, height, device,
diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp
index c63c32a..dab0ae9 100644
--- a/tests/camera2/camera2_utils.cpp
+++ b/tests/camera2/camera2_utils.cpp
@@ -176,7 +176,7 @@
}
status_t MetadataQueue::freeBuffers(List<camera_metadata_t*>::iterator start,
- List<camera_metadata_t*>::iterator end) {
+ const List<camera_metadata_t*>::iterator& end) {
while (start != end) {
free_camera_metadata(*start);
start = mStreamSlot.erase(start);
diff --git a/tests/camera2/camera2_utils.h b/tests/camera2/camera2_utils.h
index a01bae2..274ee76 100644
--- a/tests/camera2/camera2_utils.h
+++ b/tests/camera2/camera2_utils.h
@@ -65,7 +65,7 @@
private:
status_t freeBuffers(List<camera_metadata_t*>::iterator start,
- List<camera_metadata_t*>::iterator end);
+ const List<camera_metadata_t*>::iterator& end);
camera2_device_t *mDevice;
diff --git a/tests/input/evdev/InputHub_test.cpp b/tests/input/evdev/InputHub_test.cpp
index f2c8edf..14f08fc 100644
--- a/tests/input/evdev/InputHub_test.cpp
+++ b/tests/input/evdev/InputHub_test.cpp
@@ -44,8 +44,8 @@
using InputCbFunc = std::function<void(std::shared_ptr<InputDeviceNode>, InputEvent&, nsecs_t)>;
using DeviceCbFunc = std::function<void(std::shared_ptr<InputDeviceNode>)>;
-static const InputCbFunc kNoopInputCb = [](std::shared_ptr<InputDeviceNode>, InputEvent&, nsecs_t){};
-static const DeviceCbFunc kNoopDeviceCb = [](std::shared_ptr<InputDeviceNode>){};
+static const InputCbFunc kNoopInputCb = [](const std::shared_ptr<InputDeviceNode>&, InputEvent&, nsecs_t){};
+static const DeviceCbFunc kNoopDeviceCb = [](const std::shared_ptr<InputDeviceNode>&){};
class TestInputCallback : public InputCallbackInterface {
public:
@@ -53,9 +53,9 @@
mInputCb(kNoopInputCb), mDeviceAddedCb(kNoopDeviceCb), mDeviceRemovedCb(kNoopDeviceCb) {}
virtual ~TestInputCallback() = default;
- void setInputCallback(InputCbFunc cb) { mInputCb = cb; }
- void setDeviceAddedCallback(DeviceCbFunc cb) { mDeviceAddedCb = cb; }
- void setDeviceRemovedCallback(DeviceCbFunc cb) { mDeviceRemovedCb = cb; }
+ void setInputCallback(const InputCbFunc& cb) { mInputCb = cb; }
+ void setDeviceAddedCallback(const DeviceCbFunc& cb) { mDeviceAddedCb = cb; }
+ void setDeviceRemovedCallback(const DeviceCbFunc& cb) { mDeviceRemovedCb = cb; }
virtual void onInputEvent(std::shared_ptr<InputDeviceNode> node, InputEvent& event,
nsecs_t event_time) override {