I'm using Google's C++ interface to PCRE to match a single regex multiple times (possibly thousands of times). From reading the PCRE manual, it seems like a good idea to let PCRE 'study' (spend time optimizing) the regex, however, I can't seem to find a way to do that with the C++ wrapper. The pcrecpp.h
doesn't mention studying at all.
Is using pcre_study() worthwile, and if so, how can it be combined with pcrecpp and its RE class?
From a quick scan of the PCRE++ source code, it appears that "studying" is impossible with this API because the compiled RE (pcre*
) member of the RE
wrapper object is private
and there's no way to get it out or reset it.
If you want to know whether the studying optimization is worthwhile with your REs, the easiest option that I see is to copy pcrecpp.{cc,h}
into your project and hack it in; the C++ API is just some thin wrapper code. You might even want to submit a patch upstream if, like me, you like to litter open source projects with your name and copyright ;)