PCRE2_SET_OPTIMIZE(3)
π pcre2_set_optimize(3) β aka the PCRE2 glow-up page
okay so first things first, bestie: the manual name here is PCRE2 β Perl-compatible regular expressions (revised API). And the function we're stanning today is pcre2_set_optimize. It lives in the Library Functions Manual. She's a library function. She's iconic. Let's get into it. β¨
πΈ NAME πΈ
PCRE2 β Perl-compatible regular expressions (revised API)
π SYNOPSIS π
#include <pcre2.h>
int pcre2_set_optimize(pcre2_compile_context *ccontext,
uint32_t directive);
like. look at her. two arguments. one context, one directive, returns an int. no cap. π«Ά
β¨ DESCRIPTION β¨
so basically this function is the vibe control for performance optimizations. It decides which optimizations pcre2_compile() is gonna apply. π§
Here's the cute part: you can call it multiple times on the same compile context. The effects are cumulative, and if there's a conflict, the effects of later calls take precedence over earlier ones. So yeah, last word wins. main character energy honestly. π
π what you get back π
The result is:
- zero for success π
PCRE2_ERROR_NULLifccontextisNULLπPCRE2_ERROR_BADOPTIONifdirectiveis unknown π
ngl that last one is lowkey useful β you can use it to detect whether a certain optimization is even available. like a little vibe check for features. iykyk. π¦
π the directive values, bestie π
The list of possible values for the directive parameter are:
PCRE2_OPTIMIZATION_FULLβ Enable all optimizations (default) πPCRE2_OPTIMIZATION_NONEβ Disable all optimizations πPCRE2_AUTO_POSSESSβ Enable auto-possessification βPCRE2_AUTO_POSSESS_OFFβ Disable auto-possessification πPCRE2_DOTSTAR_ANCHORβ Enable implicit dotstar anchoring π₯PCRE2_DOTSTAR_ANCHOR_OFFβ Disable implicit dotstar anchoring πPCRE2_START_OPTIMIZEβ Enable start-up optimizations at match time πPCRE2_START_OPTIMIZE_OFFβ Disable start-up optimizations at match time π
and if you want the full lore, there's a complete description of the PCRE2 native API, including detailed descriptions of the directive parameter values, over in the pcre2api page. go read her. she ate. πβ¨
mwah, that's the whole page. thanks for coming to my ted talk. π
signing off from the PCRE2 10.49 era, dated 22 September 2024 β this was PCRE2_SET_OPTIMIZE(3), and she slayed. periodt. π
π
π¦ where this page comes from
- alpine 3.23: pcre2-doc 10.49-r0 Β· BSD-3-Clause
- alpine 3.24: pcre2-doc 10.49-r0 Β· BSD-3-Clause
- arch rolling: pcre2 10.49-1 Β· BSD-2-Clause AND BSD-3-Clause WITH PCRE2-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms