[Mono-dev] Patch for String.cs
Andreas Nahr
ClassDevelopment at A-SoftTech.com
Wed May 28 17:16:55 EDT 2008
> I had a look at the patches and I am happy to see these improvements in
> String code.
Thanks
> I have found several issues:
>
> > @@ -765,11 +732,13 @@
> > if (idx1 == idx2 && len1 == len2 &&
> > Object.ReferenceEquals (s1, s2))
> > return 0;
> > - if (options == CompareOptions.Ordinal)
> > - return CompareOrdinal (s1, idx1, len1, s2,
> idx2, len2);
> > + if (options == CompareOptions.Ordinal) {
> > + return String.CompareOrdinalCaseInsensitive
> (s1, idx1, s2, idx2, System.Math.Min (len1, len2));
> > + }
> > #if NET_2_0
> > - if (options == CompareOptions.OrdinalIgnoreCase)
> > - return CompareOrdinalIgnoreCase (s1, idx1,
> len1, s2, idx2, len2);
> > + if (options == CompareOptions.OrdinalIgnoreCase) {
> > + return String.CompareOrdinal (s1, idx1, s2,
> idx2, System.Math.Min (len1, len2));
> > + }
> > #endif
>
> I think that CompareOrdinalCaseInsensitive and CompareOrdinal should be
> switched.
Switched that. SimpleCollator was also just added as preview of possible
connected changes. It's not tested very well.
> > + public int LastIndexOf (String value, int startIndex)
> > + {
> > + int max = startIndex;
> > + if (max < this.Length)
>
> Others reference .length so this is inconsistent.
Length and length are completely mixed in String.cs. However as
public int Length {
get {
return length;
}
}
should get inlined anyways the difference shouldn't be noticeable. Maybe it
makes sense to unify that once the changes are complete. Maybe not ;)
Andreas
More information about the Mono-devel-list
mailing list