VitRegex - New Regular Expression (Regex) engine for Clarion

Version 1.08 of VitRegex is released:

 - changes in tryMatch to replace six bools with one byte.
   bools are equated to long so this change reduces 24 bytes to one and while
   a saving of 23 bytes sounds like no big deal, you need to remember that
   tryMatch is recursive.  We have a maximum recursion depth (that you can
   alter) where the default for maxRecursionDepth is 4096.  So at a depth of
   4096 this would save 94,208 bytes - so no longer trivial - and hence
   relieves pressure on the stack (and even more so if you decide to increase
   the allowable recursion depth).
   See the 7 bitmap equates in VitRegex.inc all prefixed tM_ for "tryMatch".

   There are two potential downsides with this change:

   - slightly longer runtime as we need to isolate and set or get individual
     bits.  Clarion's bit operations are so fast that this time is negligible.
     Furthermore we (that's the royal "we") have been able to combine some
     checks by pre-merging bitmaps so using
        tM_atomicOrLazy equate(2Ch) ! bits 2|3|5
                                    ! qIsLazy | qIsAtomic | isAtomicGroup
     where, for example, we previously had three checks
         ~qIsAtomic and ~isAtomicGroup and ~qIsLazy
     we can now do it in one check
         ~band(flags, TM_atomicOrLazy)
     so it is possible that on balance things net out timewise or even
     possible that the new code is actually a *tiny* bit faster.

   - more complex code.  Unfortunately a side effect of optimising is often
     an increase in code complexity which makes things harder to understand
     and therefore maintain. To mitigate this it is often good to increase
     comment density (both for others and your future self). Here I have
     maintained the old "equivalent" code as a comment to the right on each
     line so one can (hopefully) quickly understand what is going on.
1 Like