[Mono-list] [PATCH] System.Text.RegularExpressions won't DTRT if you re-use patterns

Juli Mallett jmallett@FreeBSD.ORG
Thu, 1 Aug 2002 04:51:01 -0700


* De: Dan Lewis <dihlewis@yahoo.co.uk> [ Data: 2002-08-01 ]
	[ Subjecte: Re: [Mono-list] [PATCH] System.Text.RegularExpressions won't DTRT if you re-use patterns ]
> Hi Juli!
> 
> Nice catch - I hadn't thought about that.

Eh, it just happened to come up in the hello world I was writing :)

> Your patch does indeed solve the problem. However the parser is now
> being called for each new expression, whether it is in the cache or not.
> Perhaps a better long term solution would be to cache a structure in the
> lookup table.

There were a lot of more elegant solutions I could come up with, however to
say I ran into that literally my first day writing C# would be no great
hyperbole.  It is a greater expense now, yes.

> At the moment, FactoryCache maps (pattern, options) => (factory). It
> could be altered to map (pattern, options) => (factory, mapping,
> group_count), so that the Regex constructor could pull these details out
> too, and save both parse and compile time.

group_count logically should be stored with the pattern yes, is there anything
else which maybe should be, too?  I wasn't very familiar with this factory
system, and so I was very hesitant to dig around and try to fix it in this
manner, especially as I did not know how right that was.  If you could do
this, that'd be great, or I could give it a go later.

Thanks much!

juli.
-- 
Juli Mallett <jmallett@FreeBSD.org>       | FreeBSD: The Power To Serve
Will break world for fulltime employment. | finger jmallett@FreeBSD.org