Author: Shivam Gupta Date: 2024-07-11T12:57:50+05:30 New Revision: a18f45f556c781d711f82043bf451fcce8324163
URL: https://github.com/llvm/llvm-project/commit/a18f45f556c781d711f82043bf451fcce8324163 DIFF: https://github.com/llvm/llvm-project/commit/a18f45f556c781d711f82043bf451fcce8324163.diff LOG: [lldb] Fix string truncation method when substring is the prefix of string (NFC) (#94785) Correct the method used to truncate the source_file string when substring is a prefix. The previous method used substr, which was changed to resize for clarity and efficiency. Caught by cppcheck - 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] Source code - source_file = source_file.substr(0, pos); Fix #91211 --------- Co-authored-by: Shivam Gupta <shivma98....@gmail.com> Added: Modified: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index e177c134fea20..50b6a5c29a657 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.resize(pos); Status error; AdbClientUP adb(GetAdbClient(error)); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits