public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Avoid extra allocations in block Date: Sun, 19 Feb 2023 23:37:04 +0000 (GMT) [thread overview] Message-ID: <20230219233704.5B2223858D20@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f52688890edd7c587ec11cf1d565f235e41a6c43 commit f52688890edd7c587ec11cf1d565f235e41a6c43 Author: Tom Tromey <tom@tromey.com> Date: Mon Jan 16 17:04:39 2023 -0700 Avoid extra allocations in block block_set_scope and block_set_using unconditionally allocate the block namespace object. However, this isn't truly needed, so arrange to only allocate when it is. Diff: --- gdb/block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdb/block.c b/gdb/block.c index 751f67d30f7..f24a2b5d084 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -320,6 +320,12 @@ void block_set_scope (struct block *block, const char *scope, struct obstack *obstack) { + if (scope == nullptr || scope[0] == '\0') + { + /* Don't bother. */ + return; + } + block_initialize_namespace (block, obstack); block->namespace_info ()->scope = scope; @@ -346,6 +352,12 @@ block_set_using (struct block *block, struct using_direct *using_decl, struct obstack *obstack) { + if (using_decl == nullptr) + { + /* Don't bother. */ + return; + } + block_initialize_namespace (block, obstack); block->namespace_info ()->using_decl = using_decl;
reply other threads:[~2023-02-19 23:37 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=20230219233704.5B2223858D20@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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).