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_NULL if ccontext is NULL πŸ’€
  • PCRE2_ERROR_BADOPTION if directive is 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