[Lldb-commits] [lldb] r161903 - /lldb/trunk/source/Breakpoint/Watchpoint.cpp
Johnny Chen
johnny.chen at apple.com
Tue Aug 14 16:09:49 PDT 2012
Author: johnny
Date: Tue Aug 14 18:09:48 2012
New Revision: 161903
URL: http://llvm.org/viewvc/llvm-project?rev=161903&view=rev
Log:
A little bit of refactoring.
Modified:
lldb/trunk/source/Breakpoint/Watchpoint.cpp
Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=161903&r1=161902&r2=161903&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Tue Aug 14 18:09:48 2012
@@ -95,6 +95,17 @@
return;
}
+// Strip at most one character from the end of the string.
+static inline std::string
+RStripOnce(const std::string &str, const char c)
+{
+ std::string res = str;
+ size_t len = res.length();
+ if (len && res.at(len - 1) == '\n')
+ res.resize(len - 1);
+ return res;
+}
+
std::string
Watchpoint::GetOldSnapshot() const
{
@@ -104,11 +115,7 @@
void
Watchpoint::SetOldSnapshot (const std::string &str)
{
- size_t len = str.length();
- m_snapshot_old_str = str;
- if (len && str.at(len - 1) == '\n')
- m_snapshot_old_str.resize(len - 1);
- return;
+ m_snapshot_old_str = RStripOnce(str, '\n');
}
std::string
@@ -121,11 +128,7 @@
Watchpoint::SetNewSnapshot (const std::string &str)
{
m_snapshot_old_str = m_snapshot_new_str;
- size_t len = str.length();
- m_snapshot_new_str = str;
- if (len && str.at(len - 1) == '\n')
- m_snapshot_new_str.resize(len - 1);
- return;
+ m_snapshot_new_str = RStripOnce(str, '\n');
}
uint64_t
More information about the lldb-commits
mailing list