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)
commit2a23dbbd22594dd94aeb3d15f152a56ab651d3ac
tree629cc5f2765d825f215ae2e80f7a28e3beed64b9
parent4cfbfdc580521753ec31b444317fba59ebbee0ae
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

Commit migrated from https://github.com/dotnet/coreclr/commit/a4b6694ed6a9d83a475b2f8003486428c1895195
src/coreclr/src/mscorlib/src/System/TimeZoneInfo.Win32.cs
src/coreclr/src/mscorlib/src/System/TimeZoneInfo.cs