Remove char[] allocations from RegistryKey and List copy to Array (#78737)
authorPoppyto <poppyto@gmail.com>
Mon, 5 Dec 2022 03:49:45 +0000 (04:49 +0100)
committerGitHub <noreply@github.com>
Mon, 5 Dec 2022 03:49:45 +0000 (22:49 -0500)
commitd47a24c1c241cfe54247b452bb65aaa26fbc906d
treec674ded1d32a091ee508bdaf4f386728688881f4
parent3855a99c9d88ed9dee53cd11c7533b53394d28d3
Remove char[] allocations from RegistryKey and List copy to Array (#78737)

* Avoid redondant verification EnsureNotDisposed() already called by SubKeyCount & ValueCount.

* Replace List by string[] to avoid List.ToArray() copy (it must handle rare cases where there are more or less elements during the loop).

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs