[Mono-dev] MS/Mono incompatibility in System.Web.HttpRequest

Edward C. Eisenbrey nede at aliquant.com
Mon Feb 13 15:25:53 EST 2006


> Pardon my instrusion, but would it not be better performance wise to 
> create static instance of the regexp to avoid doing it every time 
> CheckString called? Ie:
> 
> static Regex regex = new Regex("<[a-zA-Z\\!]+");
>


You are absolutely right.  And it would be even better if we told the
runtime to compile the regular expression once:

using System.Text.RegularExpressions;

static Regex regex = new Regex("<[a-zA-Z\\!]+", RegexOptions.Compiled);

static bool CheckString (string val)
{
	Match match = regex.Match(val);
	return match.Success;
}
 

-----Original Message-----
From: Alex Chudnovsky [mailto:alexc at majestic12.co.uk] 
Sent: Monday, February 13, 2006 3:12 PM
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] MS/Mono incompatibility in
System.Web.HttpRequest

Edward C. Eisenbrey wrote:

>using System.Text.RegularExpressions;
>
>static bool CheckString (string val)
>{
>	Regex regex = new Regex("<[a-zA-Z\\!]+");
>	Match match = regex.Match(val);
>	return match.Success;
>}
>
Pardon my instrusion, but would it not be better performance wise to 
create static instance of the regexp to avoid doing it every time 
CheckString called? Ie:

static Regex regex = new Regex("<[a-zA-Z\\!]+");

static bool CheckString (string val)
{

	Match match = regex.Match(val);
	return match.Success;
}


This is by no means not an attempt to dig at patch!

cheers

Alex


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list






More information about the Mono-devel-list mailing list