[Lldb-commits] [lldb] [LLDB][NFC] Fix a cppcheck warning in Platform/Android/PlatformAndroid.cpp (PR #94785)

via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 7 11:17:39 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Shivam Gupta (xgupta)

<details>
<summary>Changes</summary>

lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp:290:19: performance: Ineffective call of function 'substr' because a prefix of the string is assigned to itself. Use resize() or pop_back() instead. [uselessCallsSubstr]

Fix #<!-- -->91211

---
Full diff: https://github.com/llvm/llvm-project/pull/94785.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp (+1-1) 


``````````diff
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e177c134fea20..6367763dd8b4a 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec &src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-    source_file = source_file.substr(0, pos);
+    source_file = source_file.resize(0, pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

``````````

</details>


https://github.com/llvm/llvm-project/pull/94785


More information about the lldb-commits mailing list