public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Eduard-Mihai Burtescu <eddyb@lyken.rs>
Cc: Ian Lance Taylor <iant@google.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	    Ian Lance Taylor <ian@airs.com>
Subject: Re: [PATCH] Refactor rust-demangle to be independent of C++ demangling.
Date: Wed, 23 Oct 2019 16:37:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.20.13.1910231913160.15747@monopod.intra.ispras.ru> (raw)
In-Reply-To: <d544cbbb-20ad-4326-9396-f852da936c06@www.fastmail.com>

On Wed, 23 Oct 2019, Eduard-Mihai Burtescu wrote:

> @@ -384,6 +384,14 @@ rust_demangle_callback (const char *mangled, int options,
>          return 0;
>        rdm.sym_len--;
>  
> +      /* Legacy Rust symbols also always end with a path segment
> +         that encodes a 16 hex digit hash, i.e. '17h[a-f0-9]{16}'.
> +         This early check, before any parse_ident calls, should
> +         quickly filter out most C++ symbols unrelated to Rust. */
> +      if (!(rdm.sym_len > 19
> +            && !strncmp (&rdm.sym[rdm.sym_len - 19], "17h", 3)))

This can be further optimized by using memcmp in place of strncmp, since from
the length check you know that you won't see the null terminator among the three
chars you're checking.

The compiler can expand memcmp(buf, "abc", 3) inline as two comparisons against
a 16-bit immediate and an 8-bit immediate.  It can't do the same for strncmp.

Alexander

  reply	other threads:[~2019-10-23 16:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22 18:24 Eduard-Mihai Burtescu
2019-10-22 18:48 ` Ian Lance Taylor via gcc-patches
2019-10-23 14:29   ` Eduard-Mihai Burtescu
2019-10-23 16:37     ` Alexander Monakov [this message]
2019-10-23 16:41       ` Segher Boessenkool
2019-10-23 17:19         ` Jakub Jelinek
2019-10-23 17:29           ` Segher Boessenkool
2019-10-23 17:37             ` Jakub Jelinek
2019-10-23 17:43               ` Segher Boessenkool
2019-10-25 12:46       ` Eduard-Mihai Burtescu
2019-10-30 16:56         ` Eduard-Mihai Burtescu
2019-11-08 17:02           ` Eduard-Mihai Burtescu
2019-11-08 17:44             ` Ian Lance Taylor via gcc-patches
2019-11-08 19:17               ` Eduard-Mihai Burtescu
2019-11-08 19:23                 ` Ian Lance Taylor via gcc-patches
2019-11-15 21:00                   ` Eduard-Mihai Burtescu
2019-11-16 15:39                 ` Jeff Law

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=alpine.LNX.2.20.13.1910231913160.15747@monopod.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=eddyb@lyken.rs \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=iant@google.com \
    /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).