Slow performance from ImmutableList<T> Remove method in Microsoft.Bcl.Immutable

夙愿已清 提交于 2019-12-04 08:05:49

The Remove method has to scan the entire list to find the element to remove. The removal itself is O(1) because only the last element needs to be popped off. Both algorithms have quadratic performance.

Why the enormous difference in run time? Probably, because ImmutableList is a tree structure internally. This means that to scan the list there are high amounts of pointer dereferencing and unpredictable branches and memory accesses. That is very slow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!