Files
pcre2/doc/pcre2_set_optimize.3
Alex Dowad b868b411e2 Add new API function pcre2_set_optimization() for controlling enabled optimizations (#471)
It is anticipated that over time, more and more optimizations will be
added to PCRE2, and we want to be able to switch optimizations off/on,
both for testing purposes and to be able to work around bugs in a
released library version.

The number of free bits left in the compile options word is very small.
Hence, we will start putting all optimization enable/disable flags in
a separate word. To switch these off/on, the new API function
pcre2_set_optimization() will be used.

The values which can be passed to pcre2_set_optimization() are
different from the internal flag bit values. The values accepted by
pcre2_set_optimization() are contiguous integers, so there is no
danger of ever running out of them. This means in the future, the
internal representation can be changed at any time without breaking
backwards compatibility. Further, the 'directives' passed to
pcre2_set_optimization() are not restricted to control a single,
specific optimization. As an example, passing PCRE2_OPTIMIZATION_FULL
will turn on all optimizations supported by whatever version of
PCRE2 the client program happens to be linked with.

Co-authored-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Co-authored-by: Zoltan Herczeg <hzmester@freemail.hu>
2024-09-21 14:14:32 +01:00

33 lines
972 B
Groff

.TH PCRE2_SET_OPTIMIZE 3 "16 September 2024" "PCRE2 10.45"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH SYNOPSIS
.rs
.sp
.B #include <pcre2.h>
.PP
.nf
.B int pcre2_set_optimize(pcre2_compile_context *\fIccontext\fP,
.B " uint32_t \fIdirective\fP);"
.fi
.
.SH DESCRIPTION
.rs
.sp
This function controls which performance optimizations will be applied
by \fBpcre2_compile()\fP. It can be called multiple times with the same compile
context; the effects are cumulative, with the effects of later calls taking
precedence over earlier ones.
.P
The result is zero for success, PCRE2_ERROR_NULL if \fIccontext\fP is NULL,
or PCRE2_ERROR_BADOPTION if \fIdirective\fP is unknown. The latter could be
useful to detect if a certain optimization is available.
.P
There is a complete description of the PCRE2 native API, including all
permitted values for the \fIdirective\fP parameter of \fBpcre2_set_optimize()\fP,
in the
.\" HREF
\fBpcre2api\fP
.\"
page.