From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id B3EF03858025; Wed, 20 Apr 2022 12:21:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3EF03858025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Micro-optimize cooked_index_entry::full_name X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 6e0d24c448d09a27f56799102f06223ceaf6ff4d X-Git-Newrev: 72b580b8f48927cf7bc4cf8bb951aaeff637d0ee Message-Id: <20220420122158.B3EF03858025@sourceware.org> Date: Wed, 20 Apr 2022 12:21:58 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2022 12:21:58 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D72b580b8f489= 27cf7bc4cf8bb951aaeff637d0ee commit 72b580b8f48927cf7bc4cf8bb951aaeff637d0ee Author: Tom Tromey Date: Tue Apr 19 23:44:50 2022 -0600 Micro-optimize cooked_index_entry::full_name =20 I noticed that cooked_index_entry::full_name can return the canonical string when there is no parent entry. =20 Regression tested on x86-64 Fedora 34. Diff: --- gdb/dwarf2/cooked-index.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index b66ef5a1c64..d8a1ab8d30e 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -50,7 +50,7 @@ eq_entry (const void *a, const void *b) const char * cooked_index_entry::full_name (struct obstack *storage) const { - if ((flags & IS_LINKAGE) !=3D 0) + if ((flags & IS_LINKAGE) !=3D 0 || parent_entry =3D=3D nullptr) return canonical; =20 const char *sep =3D nullptr; @@ -66,13 +66,12 @@ cooked_index_entry::full_name (struct obstack *storage)= const case language_ada: sep =3D "."; break; - } =20 - if (sep =3D=3D nullptr) - return canonical; + default: + return canonical; + } =20 - if (parent_entry !=3D nullptr) - parent_entry->write_scope (storage, sep); + parent_entry->write_scope (storage, sep); obstack_grow0 (storage, canonical, strlen (canonical)); return (const char *) obstack_finish (storage); }