clang-tidy: Enable performance-faster-string-find check
This check optimizes the calls to std::string::find() when the
input passed is a single character string literal. The character
literal overload is more efficient.
Change-Id: I3c95a4214a4e858697c4b40927e0ef990ea86cef
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 5f2970b..3dcd93a 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -214,6 +214,7 @@
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-using-decls,
+performance-faster-string-find,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
diff --git a/item_updater.cpp b/item_updater.cpp
index 9bbd6c8..f624cbe 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -122,7 +122,7 @@
}
// Version id is the last item in the path
- auto pos = path.rfind("/");
+ auto pos = path.rfind('/');
if (pos == std::string::npos)
{
error("No version id found in object path: {PATH}", "PATH", path);
@@ -850,7 +850,7 @@
{
std::string path = BIOS_OBJPATH;
// Get version id from last item in the path
- auto pos = path.rfind("/");
+ auto pos = path.rfind('/');
if (pos == std::string::npos)
{
error("No version id found in object path {PATH}", "PATH", path);