diff mbox series

[v3,10/21] Refactor read_parameter_spec_from_string logic.

Message ID 20200424092132.150547-11-gprocida@google.com
State Superseded
Headers show
Series Simplify regex and suppression parsing. | expand

Commit Message

Giuliano Procida April 24, 2020, 9:21 a.m. UTC
This function extracts either a string or a regex from the same input.
This patch simplifies the string vs regex conditional logic, in order
to make following patches simpler.

There are no behavioural changes.

	* src/abg-suppression.cc (read_parameter_spec_from_string):
	Use separate string and regex variables to simplify the
	creation of returned parameter specification.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-suppression.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc
index 73e422a3..c389ed02 100644
--- a/src/abg-suppression.cc
+++ b/src/abg-suppression.cc
@@ -3090,13 +3090,15 @@  read_parameter_spec_from_string(const string& str)
 
   if (!index_str.empty() || !type_name.empty())
     {
-      function_suppression::parameter_spec* p;
+      std::string type_name_regex;
       if (is_regex)
-	p = new function_suppression::parameter_spec(atoi(index_str.c_str()),
-						     "", type_name);
-      else
-	p = new function_suppression::parameter_spec(atoi(index_str.c_str()),
-						     type_name, "");
+	{
+	  type_name_regex = type_name;
+	  type_name.clear();
+	}
+      function_suppression::parameter_spec* p =
+	new function_suppression::parameter_spec(atoi(index_str.c_str()),
+						 type_name, type_name_regex);
       result.reset(p);
     }