[Mono-list] Patch for String.Replace

Jonathan Pryor jonpryor@vt.edu
Mon, 18 Aug 2003 07:36:30 -0400


Perhaps I'm missing something, but your patch could be much simpler. 
All you need to do is, before the "ret = mono_string_new_size(...)" line
(line 351), have this:

	if (occur == 0)
		return me;

Since "occur" keeps track of how many times "oldValue" occurs within
"me", if occur is 0, you don't need to do any processing at all.  This
would require no changes to the loop as well.

 - Jon

On Mon, 2003-08-18 at 11:30, Jackson Harper wrote:
> Hello,
> 
> 	Attached is a patch that changes the behavoir of String.Replace. If the
> replace method does not alter the string at all it returns a reference
> to the unaltered string. I have been told on #mono that this is what is
> happening on MS. Would be great if some more people can confirm this.
> 
> 	I've also attached a test case that I will integrate into the unit
> tests if someone can confirm that this is the same behavoir as MS.
> 
> 
> Jackson
> 
>