[v4,09/15] Refactor read_parameter_spec_from_string logic.

Message ID 20200504123416.243214-10-gprocida@google.com
State Committed
Headers
Series Simplify regex and suppression parsing. |

Commit Message

Giuliano Procida May 4, 2020, 12:34 p.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.

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

Comments

Dodji Seketeli May 13, 2020, 7:51 a.m. UTC | #1
Giuliano Procida <gprocida@google.com> a écrit:

> 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.

Acked-by: Dodji Seketeli <dodji@seketeli.org>

Applied to master, thanks.

[...]

Cheers,
  

Patch

diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc
index c89201b6..4014ff06 100644
--- a/src/abg-suppression.cc
+++ b/src/abg-suppression.cc
@@ -3085,13 +3085,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);
     }