Question

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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top