diff mbox series

[v2,5/5] Hoist some common expressions evaluating offsets.

Message ID 20200501155148.98623-6-gprocida@google.com
State Committed
Headers show
Series Clean-ups. | expand

Commit Message

Giuliano Procida May 1, 2020, 3:51 p.m. UTC
This is for readability.

	* src/abg-suppression.cc (type_suppression::suppresses_diff):
	Hoist some constant expressions out of loops.

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

Comments

Dodji Seketeli May 11, 2020, 1:12 p.m. UTC | #1
Giuliano Procida <gprocida@google.com> a ?crit:

> This is for readability.
>
> 	* src/abg-suppression.cc (type_suppression::suppresses_diff):
> 	Hoist some constant expressions out of loops.

Applied to master, thanks!

Cheers,
diff mbox series

Patch

diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc
index 6d9a0f5f..3b02182d 100644
--- a/src/abg-suppression.cc
+++ b/src/abg-suppression.cc
@@ -770,6 +770,11 @@  type_suppression::suppresses_diff(const diff* diff) const
       && (klass_diff->first_class_decl()->get_size_in_bits()
 	  <= klass_diff->second_class_decl()->get_size_in_bits()))
     {
+      const class_decl_sptr& first_type_decl = klass_diff->first_class_decl();
+      const class_decl_sptr& second_type_decl = klass_diff->second_class_decl();
+      size_t first_type_size = first_type_decl->get_size_in_bits();
+      size_t second_type_size = second_type_decl->get_size_in_bits();
+
       for (string_decl_base_sptr_map::const_iterator m =
 	     klass_diff->inserted_data_members().begin();
 	   m != klass_diff->inserted_data_members().end();
@@ -777,10 +782,6 @@  type_suppression::suppresses_diff(const diff* diff) const
 	{
 	  decl_base_sptr member = m->second;
 	  size_t dm_offset = get_data_member_offset(member);
-	  size_t first_type_size =
-	    klass_diff->first_class_decl()->get_size_in_bits();
-	  size_t second_type_size =
-	    klass_diff->second_class_decl()->get_size_in_bits();
 	  bool matched = false;
 
 	  for (insertion_ranges::const_iterator i =
@@ -791,14 +792,10 @@  type_suppression::suppresses_diff(const diff* diff) const
 	      type_suppression::insertion_range_sptr range = *i;
 	      ssize_t range_begin_val = 0,range_end_val = 0;
 	      if (!type_suppression::insertion_range::eval_boundary
-		  (range->begin(),
-		   klass_diff->first_class_decl(),
-		   range_begin_val))
+		  (range->begin(), first_type_decl, range_begin_val))
 		break;
 	      if (!type_suppression::insertion_range::eval_boundary
-		  (range->end(),
-		   klass_diff->first_class_decl(),
-		   range_end_val))
+		  (range->end(), first_type_decl, range_end_val))
 		break;
 
 	      unsigned range_begin =