all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Eli Zaretskii <eliz@gnu.org>, Dima Kogan <lists@dima.secretsauce.net>
Cc: 24071@debbugs.gnu.org
Subject: bug#24071: [PATCH] Refactor regex character class parsing in [:name:]
Date: Wed, 27 Jul 2016 17:29:04 +0200	[thread overview]
Message-ID: <xa1t37mv3xrz.fsf@mina86.com> (raw)
In-Reply-To: <83d1m0tq25.fsf@gnu.org>

On Tue, Jul 26 2016, Eli Zaretskii wrote:
>> From: Michal Nazarewicz <mina86@mina86.com>
>> Date: Tue, 26 Jul 2016 00:54:05 +0200
>> 
>> re_wctype function is used in three separate places and in all of
>> those places almost exact code extracting the name from [:name:]
>> surrounds it.  Furthermore, re_wctype requires a NUL-terminated
>> string, so the name of the character class is copied to a temporary
>> buffer.
>> 
>> The code duplication and unnecessary memory copying can be avoided by
>> pushing the responsibility of parsing the whole [:name:] sequence to
>> the function.
>> 
>> Furthermore, since now the function has access to the length of the
>> character class name (since it’s doing the parsing), it can take
>> advantage of that information in skipping some string comparisons and
>> using a constant-length memcmp instead of strcmp which needs to take
>> care of NUL bytes.
>
> Thanks.
>
> If we are going to make some serious refactoring in regex.c, I think
> we should start with having a test suite for it.

I agree.  Which is why I started test/src/regex-tests.el¹.  Since this
patch touches only character classes I limited the tests to character
classes.

¹ If fact, the bug I’ve fixed with the previous patch was discovered
precisely because I’ve written tests for this patch.

> The dima_regex_embedded_modifiers branch, created by Dima Kogan
> (CC'ed) in the Emacs repository includes a suite taken from glibc.
> Dima, could you perhaps merge the parts of the test suite that can
> already be used to the master branch, so that we could use them to
> verify changes in regex.c?

This looks relatively straightforward;  I can take care of it.  I’ll
send a link to the result soon.

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»





  reply	other threads:[~2016-07-27 15:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 22:54 bug#24071: [PATCH] Refactor regex character class parsing in [:name:] Michal Nazarewicz
2016-07-26 14:46 ` Eli Zaretskii
2016-07-27 15:29   ` Michal Nazarewicz [this message]
2016-07-27 16:28     ` Eli Zaretskii
2016-07-27 18:30       ` Michal Nazarewicz
2016-07-27 16:50   ` bug#24071: [PATCH 1/7] New regex tests imported from glibc 2.21 Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 2/7] Added driver for the regex tests Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 3/7] Fix reading of regex-resources in regex-tests Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 4/7] Don’t (require 'cl) Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 5/7] Split regex glibc test cases into separet tests Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 6/7] Remove dead opcodes in regex bytecode Michal Nazarewicz
2016-07-27 16:50     ` bug#24071: [PATCH 7/7] Refactor regex character class parsing in [:name:] Michal Nazarewicz
2016-07-29  5:31   ` bug#24071: [PATCH] " Dima Kogan
2016-07-29  5:53     ` Eli Zaretskii
2016-07-29 13:07     ` Michal Nazarewicz
2016-08-02 16:06 ` Michal Nazarewicz
2016-08-02 16:46   ` Eli Zaretskii
2016-08-02 17:54     ` Michal Nazarewicz

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=xa1t37mv3xrz.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=24071@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lists@dima.secretsauce.net \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.