unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Naofumi Yasufuku <naofumi@yasufuku.dev>
To: Alan Mackenzie <acm@muc.de>
Cc: 57318@debbugs.gnu.org
Subject: bug#57318: 29.0.50; c++-mode: Functions are shown as variables: partial template specialization
Date: Thu, 01 Sep 2022 01:01:56 +0900	[thread overview]
Message-ID: <m11qsw8kqz.fsf@yasufuku.dev> (raw)
In-Reply-To: <Yw5sQJcT9ypvMX14@ACM>

[-- Attachment #1: Type: text/plain, Size: 2850 bytes --]

Hello Alan,

Alan Mackenzie <acm@muc.de> writes:

> Hello, Naofumi.
>
> Thank you indeed for your bug report, and thanks even more for
> diagnosing the cause and writing a patch!
>
> I'm truly astounded that you managed to debug this problem, hidden as it
> was in the fontification parts of CC Mode, which are difficult to run
> with the debugger.  Respect!
>

Thank you, I'm glad to hear that.

> Looking at your patch, I can see one or two problems with it.  The main
> one is that after encountering a template opener "<", I'm a bit worried
> about the accuracy of checking for the matching ">".
>
> Looking further into the problem, it seems the misfontification bug was
> triggered by the commas in the template expressions.  When there's a
> comma there, the (c-forward-<>-arglist ...) call (which "; Should always
> work") fails.  This failure is caused by the dynamic binding of
> c-restricted-<>-arglists to t.
>
> When this dynamic binding is instead at nil (rather than t), the
> fontification works properly, with functions fontified as functions.
> The reason for this faulty binding was fixing a bug report where
> scrolling a buffer containing lots of templates was very slow.  Binding
> c-restricted-<>-arglists to t "solved" that slowness.
>

Indeed.  I confirmed that avoiding (c-restricted-<>-arglists t) binding
solves this misfontification problem at least, but it makes scrolling
terribly slow...

> That slowness had been caused by inefficient scanning of the template
> structures.  I've now identified and implemented an alternative
> optimisation, which doesn't cause problems with commas in templates.
>
[..snip..]
> Can I ask you, please, to apply and test my proposed patch, which I
> enclose below.  Would you please test it on your real C++ source code,
> and either confirm it really works, or say what's still faulty about it.
> If there are any problems with applying the patch, feel free to send me
> personal email.
>

I've applied your patch.  It works well and solves misfontification
problem.  At the same time, I've not seen any noticeable performance
degradation by this patch so far.  Great.

  attachment: fix_c-restricted--arglists_verification.png

I came across this problem when I tried to compare the current
tree-sitter's fontification quality and performance with familiar
cc-mode by using very-fast flat_hash_map code [1][2].  Now problematic
fontification has gone.

> So I must apologize that I won't be using your patch, but I thoroughly
> appreciate the time you must have spent debugging the problem.
>

That's just fine with me.  I don't mind at all because I'm not an
expert.  Fixing the root cause should be done.

Best regards,
  Naofumi

[1] https://github.com/skarupke/flat_hash_map/blob/master/flat_hash_map.hpp
[2] https://probablydance.com/2017/02/26/i-wrote-the-fastest-hashtable/



[-- Attachment #2: verification --]
[-- Type: image/png, Size: 468337 bytes --]

  reply	other threads:[~2022-08-31 16:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-21 13:27 bug#57318: 29.0.50; c++-mode: Functions are shown as variables: partial template specialization Naofumi Yasufuku
2022-08-28  5:33 ` Naofumi Yasufuku
2022-08-30 20:00   ` Alan Mackenzie
2022-08-31 16:01     ` Naofumi Yasufuku [this message]
2022-08-31 19:26       ` Alan Mackenzie

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m11qsw8kqz.fsf@yasufuku.dev \
    --to=naofumi@yasufuku.dev \
    --cc=57318@debbugs.gnu.org \
    --cc=acm@muc.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).