summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2020-03-09 16:17:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-09 16:17:21 +0000
commitea59f9c057940659973bae6eab9b79b6d038125f (patch)
treece925a3d2db1932aeb34d5ab9c620f798c5ea5c6
parent8a7fdd8cd8237d75f5e6a2e649d9d47fe050328a (diff)
parente518fc39f5656debfa66dde71b04edecefa4ee32 (diff)
downloadplatform_system_libhidl-ea59f9c057940659973bae6eab9b79b6d038125f.tar.gz
platform_system_libhidl-ea59f9c057940659973bae6eab9b79b6d038125f.tar.bz2
platform_system_libhidl-ea59f9c057940659973bae6eab9b79b6d038125f.zip
Merge "libhidl: allocate rarely used regex only if needed" into rvc-dev
-rw-r--r--transport/ServiceManagement.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 19d1d52e..36010167 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -54,10 +54,6 @@
#include <android/hidl/manager/1.2/BpHwServiceManager.h>
#include <android/hidl/manager/1.2/IServiceManager.h>
-#define RE_COMPONENT "[a-zA-Z_][a-zA-Z_0-9]*"
-#define RE_PATH RE_COMPONENT "(?:[.]" RE_COMPONENT ")*"
-static const std::regex gLibraryFileNamePattern("(" RE_PATH "@[0-9]+[.][0-9]+)-impl(.*?).so");
-
using ::android::hidl::base::V1_0::IBase;
using IServiceManager1_0 = android::hidl::manager::V1_0::IServiceManager;
using IServiceManager1_1 = android::hidl::manager::V1_1::IServiceManager;
@@ -263,7 +259,14 @@ static std::vector<std::string> findFiles(const std::string& path, const std::st
return results;
}
-bool matchPackageName(const std::string& lib, std::string* matchedName, std::string* implName) {
+static bool matchPackageName(const std::string& lib, std::string* matchedName,
+ std::string* implName) {
+#define RE_COMPONENT "[a-zA-Z_][a-zA-Z_0-9]*"
+#define RE_PATH RE_COMPONENT "(?:[.]" RE_COMPONENT ")*"
+ static const std::regex gLibraryFileNamePattern("(" RE_PATH "@[0-9]+[.][0-9]+)-impl(.*?).so");
+#undef RE_PATH
+#undef RE_COMPONENT
+
std::smatch match;
if (std::regex_match(lib, match, gLibraryFileNamePattern)) {
*matchedName = match.str(1) + "::I*";