dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.07k stars 1.17k forks source link

Remove ArrayLists from WPF / XPS to improve code and performance #6426

Open wstaelens opened 2 years ago

wstaelens commented 2 years ago

https://github.com/dotnet/wpf/blob/89d172db0b7a192de720c6cfba5e28a1e7d46123/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Primitive.cs#L1999

ArrayList? why not List?

https://github.com/dotnet/wpf/blob/89d172db0b7a192de720c6cfba5e28a1e7d46123/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Flattener.cs#L101

https://github.com/dotnet/wpf/blob/89d172db0b7a192de720c6cfba5e28a1e7d46123/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlStream.cs#L577

https://github.com/dotnet/wpf/search?l=C%23&q=arraylist

all versions

IAmTheCShark commented 2 years ago

My wild guess is that List<T> didnt exist when the code was written. Also they are basically identical in terms of code, the only improvement here is getting rid of boxing in a few places, but mostly it wouldn't improve at all.

wstaelens commented 2 years ago

@IAmTheCShark just search arraylist VS list and you will find many reasons why it will boost performance.

WPF/XPS code should be made up-to-date for .net (core).

(My 1st hit: https://stackoverflow.com/a/59379803 )

IAmTheCShark commented 2 years ago

@IAmTheCShark just search arraylist VS list and you will find many reasons why it will boost performance.

WPF/XPS code should be made up-to-date for .net (core).

(My 1st hit: https://stackoverflow.com/a/59379803 )

Again, the only difference is when value types are involved (boxing), and that is not so often. Look at your first Link when List<string> is compared to ArrayListin below the screenshots.