From: <Joe...@t-...> - 2021-04-25 15:58:25
|
Hi, >(defstruct compiled-regexp value) Pascal Bourguignon's response to Dan Stanger was quite exhaustive, yet I'd add another suggestion: If you go the defstruct or defclass route, you could add a call to FFI:VALIDP to assess whether the FFI pointer is still valid. If not, you could recompile the regexp (after you add the source slot to the defstruct) – and replace the stale pointer. FFI:VALIDP allows you to detect (or mark) stale pointers, such as all those emanating from a prior image. https://clisp.sourceforge.io/impnotes/dffi.html The benefit is that the freshly recompiled regexp would work after you save an image and restart from that image – in case you like to work with your own images, e.g. in the context of a fast start from a web server. However, there will still be multiple regexp compilation times, one after each process start. If the Lisp-only solution (e.g. CL-PPCRE) is ok with you, its benefit is that Lisp objects (including closures) live on when restored from an image (that's the whole idea), so the regex would be compiled once only. As a result, even if CL-PPCRE were slower (I don't know) than the POSIX regexp module, using it might still end up faster when using images, due to lack of recompilation. You'll have to check. Regards, Jörg Höhle |