Skip to content

Commit a18f45f

Browse files
xguptaShivam Gupta
and
Shivam Gupta
authored
[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 <[email protected]>
1 parent 6a90769 commit a18f45f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec &src_file_spec,
287287
static constexpr llvm::StringLiteral k_zip_separator("!/");
288288
size_t pos = source_file.find(k_zip_separator);
289289
if (pos != std::string::npos)
290-
source_file = source_file.substr(0, pos);
290+
source_file.resize(pos);
291291

292292
Status error;
293293
AdbClientUP adb(GetAdbClient(error));

0 commit comments

Comments
 (0)