From f9d90bc5f690de43cbfd8bd15f6f3d3e01471615 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 20 Aug 2019 09:24:20 +0000 Subject: [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 --- .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 6 +++--- .../RenderScriptRuntime/RenderScriptRuntime.cpp | 17 ++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'lldb/source/Plugins/LanguageRuntime') diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index cfec2de1fb9..1ff3fc42dd0 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -582,9 +582,9 @@ protected: case 0: break; case 1: { - regex_up.reset(new RegularExpression()); - if (!regex_up->Compile(llvm::StringRef::withNullAsEmpty( - command.GetArgumentAtIndex(0)))) { + regex_up.reset(new RegularExpression( + llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0)))); + if (!regex_up->IsValid()) { result.AppendError( "invalid argument - please provide a valid regular expression"); result.SetStatus(lldb::eReturnStatusFailed); diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index 2e0c8d52ddd..38bd79d68cf 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -442,21 +442,12 @@ bool ParseCoordinate(llvm::StringRef coord_s, RSCoordinate &coord) { // elements fails the contents of &coord are undefined and `false` is // returned, `true` otherwise - RegularExpression regex; llvm::SmallVector matches; - bool matched = false; - if (regex.Compile(llvm::StringRef("^([0-9]+),([0-9]+),([0-9]+)$")) && - regex.Execute(coord_s, &matches)) - matched = true; - else if (regex.Compile(llvm::StringRef("^([0-9]+),([0-9]+)$")) && - regex.Execute(coord_s, &matches)) - matched = true; - else if (regex.Compile(llvm::StringRef("^([0-9]+)$")) && - regex.Execute(coord_s, &matches)) - matched = true; - - if (!matched) + if (!RegularExpression("^([0-9]+),([0-9]+),([0-9]+)$") + .Execute(coord_s, &matches) && + !RegularExpression("^([0-9]+),([0-9]+)$").Execute(coord_s, &matches) && + !RegularExpression("^([0-9]+)$").Execute(coord_s, &matches)) return false; auto get_index = [&](size_t idx, uint32_t &i) -> bool { -- cgit v1.2.3