jtmueller / Collections.Pooled

Fast, low-allocation ports of List, Dictionary, HashSet, Stack, and Queue using ArrayPool and Span.
MIT License
554 stars 48 forks source link

allow access span to read out (e.g. during custom serialization) #9

Closed dzmitry-lahoda closed 5 years ago

jtmueller commented 5 years ago

I've got no issue with this change, but now that I look closer, I think it's interesting that the base List class implements IReadOnlyList, but the AsReadOnly method wraps the entire List in a ReadOnlyCollection. I suppose it's so you can't simply cast back to List or IList and start modifying things, but it does mean you won't have access to your new property if you use AsReadOnly

dzmitry-lahoda commented 5 years ago

I will think about it. The idea is that all read only code may work with readonly list as it was before. But when instance reaches serialization layer than it has readonly span.