Remember AdjustementRule index
authorEric Erhardt <eric.erhardt@microsoft.com>
Sat, 15 Apr 2017 16:54:29 +0000 (11:54 -0500)
committerEric Erhardt <eric.erhardt@microsoft.com>
Sat, 15 Apr 2017 17:22:14 +0000 (12:22 -0500)
commita4b6694ed6a9d83a475b2f8003486428c1895195
tree5e309008ca94c884668c366d55bc50ef90df79f3
parent3aec163d4a1431b89f6e1ec22d9b88c13b399a66
Remember AdjustementRule index

Profiling TimeZoneInfo scenarios on Unix shows most of the time being spent in GetPreviousAdjustmentRule. This is because we need to scan all of the AdjustmentRules, looking for the specified rule, and then getting the one before it.

This change remembers the AdjustmentRule index when passing the AdjustmentRule into GetPreviousAdjustmentRule. This allows us to not scan all the rules, and increases the performance of DateTime.Now significantly in time zones that have daylight savings time.

Fix https://github.com/dotnet/corefx/issues/3571
src/mscorlib/src/System/TimeZoneInfo.Win32.cs
src/mscorlib/src/System/TimeZoneInfo.cs