Performance issue: comparing to String.Format

后端 未结 6 501
攒了一身酷
攒了一身酷 2020-12-08 22:32

A while back a post by Jon Skeet planted the idea in my head of building a CompiledFormatter class, for using in a loop instead of String.Format().

6条回答
  •  醉梦人生
    2020-12-08 22:38

    The framework provides explicit overrides to the format methods that take fixed-sized parameter lists instead of the params object[] approach to remove the overhead of allocating and collecting all of the temporary object arrays. You might want to consider that for your code as well. Also, providing strongly-typed overloads for common value types would reduce boxing overhead.

提交回复
热议问题