diff mbox series

[6/6] Hoist some common expressions evaluating offsets.

Message ID 20200429175133.19814-7-gprocida@google.com
State Superseded
Headers show
Series Clean-ups | expand

Commit Message

Giuliano Procida April 29, 2020, 5:51 p.m. UTC
This is for readability.

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

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