On Wed, Aug 02, 2017 at 03:01:53PM +0200, Pino Toscano wrote: > On Wednesday, 2 August 2017 13:52:06 CEST Richard W.M. Jones wrote: > > I think you're suggesting this: > > > > let m = PCRE.exec re "ccaaaabb" in > > if PCRE.matches m then ( > > let whole = PCRE.sub m 0 in > > Not really, my suggestion was to have a separate object representing > the result of a regex match -- much like other language have in their > regex APIs. > > OTOH, this solution LGTM as well: the result of the regex is not saved > in a thread-local variable, but directly in the same regex object, so > can be kept/used around, and it is GC'ed when not needed anymore. > If you could apply that change, that'd be a LGTM.
But the problem still is this makes the if/else chains more awkward. What's really wrong with the thread-local variable? It only stores a single string and a vector of integers per thread (at most). The final string/vector is reliably freed on exit - I know that because I've checked it with valgrind. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
