[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24071: [PATCH] Refactor regex character class parsing in [:name:]
From: |
Michal Nazarewicz |
Subject: |
bug#24071: [PATCH] Refactor regex character class parsing in [:name:] |
Date: |
Wed, 27 Jul 2016 17:29:04 +0200 |
User-agent: |
Notmuch/0.19+53~g2e63a09 (http://notmuchmail.org) Emacs/25.1.50.1 (x86_64-unknown-linux-gnu) |
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»
- bug#24071: [PATCH] Refactor regex character class parsing in [:name:], Michal Nazarewicz, 2016/07/25
- bug#24071: [PATCH] Refactor regex character class parsing in [:name:], Eli Zaretskii, 2016/07/26
- bug#24071: [PATCH] Refactor regex character class parsing in [:name:],
Michal Nazarewicz <=
- bug#24071: [PATCH 1/7] New regex tests imported from glibc 2.21, Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 3/7] Fix reading of regex-resources in regex-tests, Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 4/7] Don’t (require 'cl), Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 7/7] Refactor regex character class parsing in [:name:], Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 5/7] Split regex glibc test cases into separet tests, Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 6/7] Remove dead opcodes in regex bytecode, Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH 2/7] Added driver for the regex tests, Michal Nazarewicz, 2016/07/27
- bug#24071: [PATCH] Refactor regex character class parsing in [:name:], Dima Kogan, 2016/07/29