[Lldb-commits] [PATCH] D75294: [lldb][NFC] Minor code cleanup in Editline.cpp
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 5 16:27:01 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG467969161d94: [lldb/Core] Minor code cleanup in Editline.cpp (NFC) (authored by gedatsu217, committed by JDevlieghere).
Changed prior to commit:
https://reviews.llvm.org/D75294?vs=247953&id=248628#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75294/new/
https://reviews.llvm.org/D75294
Files:
lldb/source/Host/common/Editline.cpp
Index: lldb/source/Host/common/Editline.cpp
===================================================================
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -144,10 +144,10 @@
while (start < input.length()) {
size_t end = input.find('\n', start);
if (end == std::string::npos) {
- result.insert(result.end(), input.substr(start));
+ result.push_back(input.substr(start));
break;
}
- result.insert(result.end(), input.substr(start, end - start));
+ result.push_back(input.substr(start, end - start));
start = end + 1;
}
return result;
@@ -302,19 +302,16 @@
// Editline private methods
void Editline::SetBaseLineNumber(int line_number) {
- std::stringstream line_number_stream;
- line_number_stream << line_number;
m_base_line_number = line_number;
m_line_number_digits =
- std::max(3, (int)line_number_stream.str().length() + 1);
+ std::max<int>(3, std::to_string(line_number).length() + 1);
}
std::string Editline::PromptForIndex(int line_index) {
bool use_line_numbers = m_multiline_enabled && m_base_line_number > 0;
std::string prompt = m_set_prompt;
- if (use_line_numbers && prompt.length() == 0) {
+ if (use_line_numbers && prompt.length() == 0)
prompt = ": ";
- }
std::string continuation_prompt = prompt;
if (m_set_continuation_prompt.length() > 0) {
continuation_prompt = m_set_continuation_prompt;
@@ -429,7 +426,7 @@
}
int Editline::CountRowsForLine(const EditLineStringType &content) {
- auto prompt =
+ std::string prompt =
PromptForIndex(0); // Prompt width is constant during an edit session
int line_length = (int)(content.length() + prompt.length());
return (line_length / m_terminal_width) + 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75294.248628.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200306/a863dcfd/attachment.bin>
More information about the lldb-commits
mailing list