문제

I have a relatively small dictionary (a few hundred entries at most) that is receiving many calls (hundreds, possibly thousands per second) and many of them requires entry modification.

Performance wise, which one of this solution is generally recommended for a small list with frequent updates?

  1. unboxing-boxing structs
  2. define structure methods for each parameter that requires modification
  3. use classes, that can be directly modified because they are referenced unlike structures
도움이 되었습니까?

해결책

You should really avoid mutable value types (i.e. structures that can be modified) if at all possible, as it basically breaks the concept of a "value type" if one or more attributes of a value are not intrinsically part of the value itself (and thus can't be changed). If you need to store values that can be changed, then you should be using a class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top