summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/RegularExpression.cpp
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2019-08-20 09:24:20 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2019-08-20 09:24:20 +0000
commitf9d90bc5f690de43cbfd8bd15f6f3d3e01471615 (patch)
tree3c62c4c7ea05d724f34236e40c08bf1526f0d5ac /lldb/source/Utility/RegularExpression.cpp
parent12d83b427015083f40964c706a5b9e428d9d88df (diff)
downloadbcm5719-llvm-f9d90bc5f690de43cbfd8bd15f6f3d3e01471615.tar.gz
bcm5719-llvm-f9d90bc5f690de43cbfd8bd15f6f3d3e01471615.zip
[lldb] D66174 `RegularExpression` cleanup
I find as a good cleanup to drop the Compile method. As I do not find TIMTOWTDI as an advantage and there is already constructor parameter to compile the regex. Differential Revision: https://reviews.llvm.org/D66392 llvm-svn: 369352
Diffstat (limited to 'lldb/source/Utility/RegularExpression.cpp')
-rw-r--r--lldb/source/Utility/RegularExpression.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp
index 356d78a041f..432b45ee4c4 100644
--- a/lldb/source/Utility/RegularExpression.cpp
+++ b/lldb/source/Utility/RegularExpression.cpp
@@ -12,22 +12,19 @@
using namespace lldb_private;
-RegularExpression::RegularExpression(llvm::StringRef str) { Compile(str); }
+RegularExpression::RegularExpression(llvm::StringRef str)
+ : m_regex_text(str),
+ // m_regex does not reference str anymore after it is constructed.
+ m_regex(llvm::Regex(str)) {}
RegularExpression::RegularExpression(const RegularExpression &rhs)
- : RegularExpression() {
- Compile(rhs.GetText());
-}
-
-bool RegularExpression::Compile(llvm::StringRef str) {
- m_regex_text = str;
- m_regex = llvm::Regex(str);
- return IsValid();
-}
+ : RegularExpression(rhs.GetText()) {}
bool RegularExpression::Execute(
llvm::StringRef str,
llvm::SmallVectorImpl<llvm::StringRef> *matches) const {
+ if (!IsValid())
+ return false;
return m_regex.match(str, matches);
}
OpenPOWER on IntegriCloud