Why is this List<>.IndexOf code so much faster than the List[i] and manual compare?

前端 未结 3 1760
无人共我
无人共我 2021-02-06 02:30

I\'m running AQTime on this piece of code, I found that .IndexOf takes 16% of the time vs close to 80% for the other piece... They appear to use the same IsEqual and other rout

3条回答
  •  迷失自我
    2021-02-06 03:10

    What's the type of _pCoord3Points? If the element type is a value type which only overrides Equals(object) then it's possible that IndexOf is repeatedly boxing values to check for equality. That might explain it. It's really just guesswork at this point though... if you could provide a short but complete program which demonstrates the problem, that would make it a lot easier to help you.

提交回复
热议问题