mono / gtk-sharp

Gtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
http://www.mono-project.com/GtkSharp
Other
428 stars 140 forks source link

[List] Don't cache the Count value. #159

Closed Therzok closed 8 years ago

knocte commented 7 years ago

You stated the what, but not the why.

meebey commented 7 years ago

Seems like to save 32bit as class member. More interesting is that it was only invalidated in FreeList, as the list size was static?

Therzok commented 7 years ago

Yes, you are right, I did not state the why.

The problem is that if by per-chance you iterate the list created from managed and append more elements, the list size is wrong and you won't iterate everything.

Therzok commented 7 years ago

This is for API correctness, SList/List should not be iterated via indexer and Count. (since it's an O(n^3) operation)

knocte commented 7 years ago

Ok thanks. Given that this is a clear bugfix I guess we can include this one in the next 3.0 release, so you can forward port now if you want (and include the why in the forward port commit).