Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Switch to using pcre::regex instead of boost::regex #190

Closed
wants to merge 5 commits into from

Conversation

vadz
Copy link
Collaborator

@vadz vadz commented Aug 21, 2021

Drop dependency on Boost.Regex library and use PCRE-based regex class
instead.

Using PCRE-based implementation is advantageous compared to using
std::regex because it has a much better performance and also has more
features, notably it supports "?<=" look-behind assertions not supported
by the standard class, that are used in the existing code.

The only regex change needed was the one replacing "\l", which is not
recognized by PCRE (nor std::regex) as a character class shorthand, with
the explicit use of "[:lower:]".

Currently PCRE is used only under POSIX systems and so the fully
functional version of test_coding_rules tool can only be built there
and a stub version, which simply outputs an error, is built by default
under MSW. This shouldn't be a problem in practice, because this tool is
only used during lmi development, which is done only on POSIX platforms.

@vadz vadz force-pushed the use-pcre branch 2 times, most recently from 481c719 to f4a679d Compare September 5, 2021 14:20
Drop dependency on Boost.Regex library and use PCRE-based regex class
instead.

Using PCRE-based implementation is advantageous compared to using
std::regex because it has a much better performance and also supports
more regex features, notably the "?<=" look-behind assertions not
supported by the standard class, that are used in the existing code.

With PCRE, the only regex change needed was the one replacing "\l",
which is not recognized by PCRE (nor std::regex) as a character class
shorthand, with the explicit use of "[:lower:]".

Currently PCRE is used only under POSIX systems and so the fully
functional version of test_coding_rules tool can only be built there
and a stub version, which simply outputs an error, is built by default
under MSW. This shouldn't be a problem in practice, because this tool is
only used during lmi development, which is done only on POSIX platforms.

The regex unit test has been minimally modified to build, and pass,
without Boost.Regex.

Finally, remove the last vestiges of Boost libraries from configure and
automake makefiles.
Compare PCRE performance with std::regex under POSIX systems, where PCRE
is available.

The results show that PCRE is 6-12 times faster, even with the simplest
possible regexes used in this test, with gcc 10 (previous
test_coding_rules benchmarks show that the difference is even more
pronounced with more complex regexes or older gcc versions).
The changes of a9bc62f (Count coding-rules complaints, 2021-06-28)
made test_coding_rules exit with a non-zero exit code if any coding
rules violations were found, but the check_concinnity makefile target
still explicitly ignored the failure by using "-" in the make recipe.

It is not really clear why was the exit code of test_coding_rules
ignored in the first place, as it hadn't been done for the checks
performed in the makefile itself prior to the introduction of a separate
test_coding_rules program in 7afe844 (Quadruple the speed of 'make
check_conformity', 2006-01-18), but it remained the case ever since.

Stop doing it now and do fail if either any real problems are found or
when running the stub version of test_coding_rules built on the systems
without PCRE.
Because only Linux version of this tool is fully functional (while the
MSW one just exits with an error), always use it, even in the build
targeting MSW.

This is enough to make concinnity checks to work in any build.
@vadz vadz marked this pull request as ready for review September 18, 2021 13:14
@vadz
Copy link
Collaborator Author

vadz commented Oct 3, 2021

Merged as 368ee55 and preceding commits.

@vadz vadz closed this Oct 3, 2021
@vadz vadz deleted the use-pcre branch October 3, 2021 22:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant