[Mono-dev] : DateTime.Parse patch
Atsushi Eno
atsushi at ximian.com
Wed Aug 15 23:19:16 EDT 2007
Hello,
I like the effort to improve DateTime.Parse(), but I think your
approach is broken. The switch-case that looks at
DateTimeFormatInfo.CultureID could be problematic especially
when a DateTimeFormatInfo is cloned and then its format strings
are modified (note that there are setters on DateTimeFormatInfo
members).
Atsushi Eno
Eyal Alaluf wrote:
> Hi, all.
>
> Attached is a patch for the infamous DateTime.Parse method.
> The current logic for Parse is to try all the culture date time formats
> and then try some special formats in invariant culture.
> This solution is not sufficient because it is not very compatible with
> MS behavior, it is difficult to maintain and is very inefficient.
>
> The current patch aims to improve all of these issues. The patch defines
> two sets of formats 'date' only formats and 'time' only formats.
> The Parse method will check all the date formats for a match. If the
> date format matches the string beginning it will combine it with all the
> time formats. It will check similarly all the time formats and match to
> them the date formats.
> Only if this fails it will look at all the culture date formats (making
> the TrypParse negative flow still very slow). This is done because
> additional effort is required to define the culture specific separators.
> The result is that many more formats are recognizable by DateTime.Parse
> and that it is easier to add formats if necessary.
>
> In different flows the patch improves performance by a factor of 3-5
> times on Mono.
>
> Please review and provide feedback since this is a fairly major change
> to a really sensitive spot.
>
> Eyal.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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