public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applying to mainline] ir: Cache internal name for several types
Date: Mon, 12 Feb 2024 22:31:42 +0100	[thread overview]
Message-ID: <87mss5xtc1.fsf@redhat.com> (raw)

Hello,

Profiling showed that computing function type names while sorting
types prior to type hashing was taking a lot of time.  Caching
function, reference, pointers and qualified type names reduces that
time a lot.

This is what this patch does, in prevision for the up coming type
hashing patch.

	* src/abg-ir.cc ({qualified_type_def, pointer_type_def,
	reference_type_def}::get_qualified_name): Cache the internal
	qualified type name for non-canonicalized types.
	(function_type::get_cached_name): Cache the internal function type
	name.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch.
---
 src/abg-ir.cc | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index f4d9174f..9f053aef 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -17241,7 +17241,8 @@ qualified_type_def::get_qualified_name(bool internal) const
 	  // We are asked to return a temporary *internal* name.
 	  // Lets compute it and return a reference to where it's
 	  // stored.
-	  priv_->temporary_internal_name_ =
+	  if (priv_->temporary_internal_name_.empty())
+	    priv_->temporary_internal_name_ =
 	      env.intern(build_name(true, /*internal=*/true));
 	  return priv_->temporary_internal_name_;
 	}
@@ -17734,7 +17735,8 @@ pointer_type_def::get_qualified_name(bool internal) const
 	  // cache where we store its name at each invocation of this
 	  // function.
 	  if (pointed_to_type)
-	    priv_->temp_internal_qualified_name_ =
+	    if (priv_->temp_internal_qualified_name_.empty())
+	      priv_->temp_internal_qualified_name_ =
 		pointer_declaration_name(this,
 					 /*variable_name=*/"",
 					 /*qualified_name=*/
@@ -18141,14 +18143,15 @@ reference_type_def::get_qualified_name(bool internal) const
 	  // cache where we store its name at each invocation of this
 	  // function.
 	  if (pointed_to_type)
-	    priv_->temp_internal_qualified_name_ =
-	      get_name_of_reference_to_type(*pointed_to_type,
-					    is_lvalue(),
-					    /*qualified_name=*/
-					    is_typedef(pointed_to_type)
-					    ? false
-					    : true,
-					    /*internal=*/true);
+	    if (priv_->temp_internal_qualified_name_.empty())
+	      priv_->temp_internal_qualified_name_ =
+		get_name_of_reference_to_type(*pointed_to_type,
+					      is_lvalue(),
+					      /*qualified_name=*/
+					      is_typedef(pointed_to_type)
+					      ? false
+					      : true,
+					      /*internal=*/true);
 	  return priv_->temp_internal_qualified_name_;
 	}
     }
@@ -21550,9 +21553,9 @@ function_type::get_cached_name(bool internal) const
 	}
       else
 	{
-	  priv_->temp_internal_cached_name_ =
-	    get_function_type_name(this,
-				   /*internal=*/true);
+	  if (priv_->temp_internal_cached_name_.empty())
+	    priv_->temp_internal_cached_name_ =
+	      get_function_type_name(this, /*internal=*/true);
 	  return priv_->temp_internal_cached_name_;
 	}
     }
-- 
2.39.3


-- 
		Dodji


                 reply	other threads:[~2024-02-12 21:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mss5xtc1.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).