Use const reference in setGpuStats() API
Rather than make a copy of these strings when the function is
called, we pass them by const reference.
Test: TreeHugger
Change-Id: Ief53fea1f6df191181e00eab978cf53b5a2ab91d
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index c20d54b..9a28ec7 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -156,9 +156,9 @@
mDriverPath = path;
}
-void GraphicsEnv::setGpuStats(const std::string driverPackageName,
- const std::string driverVersionName, const uint64_t driverVersionCode,
- const std::string appPackageName) {
+void GraphicsEnv::setGpuStats(const std::string& driverPackageName,
+ const std::string& driverVersionName,
+ const uint64_t driverVersionCode, const std::string& appPackageName) {
ATRACE_CALL();
ALOGV("setGpuStats:\n"
diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp
index 98a6395..762a27b 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -27,9 +27,9 @@
public:
explicit BpGpuService(const sp<IBinder>& impl) : BpInterface<IGpuService>(impl) {}
- virtual void setGpuStats(const std::string driverPackageName,
- const std::string driverVersionName, const uint64_t driverVersionCode,
- const std::string appPackageName) {
+ virtual void setGpuStats(const std::string& driverPackageName,
+ const std::string& driverVersionName, const uint64_t driverVersionCode,
+ const std::string& appPackageName) {
Parcel data, reply;
data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index d4edfa0..f48d887 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -47,8 +47,8 @@
// /data/app/com.example.driver/base.apk!/lib/arm64-v8a
void setDriverPath(const std::string path);
android_namespace_t* getDriverNamespace();
- void setGpuStats(const std::string driverPackageName, const std::string driverVersionName,
- const uint64_t versionCode, const std::string appPackageName);
+ void setGpuStats(const std::string& driverPackageName, const std::string& driverVersionName,
+ const uint64_t versionCode, const std::string& appPackageName);
void sendGpuStats();
bool shouldUseAngle(std::string appName);
diff --git a/libs/graphicsenv/include/graphicsenv/IGpuService.h b/libs/graphicsenv/include/graphicsenv/IGpuService.h
index c080c53..1e74d60 100644
--- a/libs/graphicsenv/include/graphicsenv/IGpuService.h
+++ b/libs/graphicsenv/include/graphicsenv/IGpuService.h
@@ -32,9 +32,9 @@
DECLARE_META_INTERFACE(GpuService);
// set GPU stats from GraphicsEnvironment.
- virtual void setGpuStats(const std::string driverPackageName,
- const std::string driverVersionName, const uint64_t driverVersionCode,
- const std::string appPackageName) = 0;
+ virtual void setGpuStats(const std::string& driverPackageName,
+ const std::string& driverVersionName, const uint64_t driverVersionCode,
+ const std::string& appPackageName) = 0;
};
class BnGpuService : public BnInterface<IGpuService> {
diff --git a/services/gpuservice/GpuService.cpp b/services/gpuservice/GpuService.cpp
index 9906dea..68c185c 100644
--- a/services/gpuservice/GpuService.cpp
+++ b/services/gpuservice/GpuService.cpp
@@ -37,9 +37,9 @@
GpuService::GpuService() = default;
-void GpuService::setGpuStats(const std::string driverPackageName,
- const std::string driverVersionName, const uint64_t driverVersionCode,
- const std::string appPackageName) {
+void GpuService::setGpuStats(const std::string& driverPackageName,
+ const std::string& driverVersionName, const uint64_t driverVersionCode,
+ const std::string& appPackageName) {
ATRACE_CALL();
std::lock_guard<std::mutex> lock(mStateLock);
diff --git a/services/gpuservice/GpuService.h b/services/gpuservice/GpuService.h
index edfd364..5304fa1 100644
--- a/services/gpuservice/GpuService.h
+++ b/services/gpuservice/GpuService.h
@@ -37,8 +37,8 @@
private:
// IGpuService interface
- void setGpuStats(const std::string driverPackageName, const std::string driverVersionName,
- const uint64_t driverVersionCode, const std::string appPackageName);
+ void setGpuStats(const std::string& driverPackageName, const std::string& driverVersionName,
+ const uint64_t driverVersionCode, const std::string& appPackageName);
// GpuStats access must be protected by mStateLock
std::mutex mStateLock;