Performance issue: comparing to String.Format

后端 未结 6 619
攒了一身酷
攒了一身酷 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:50

    It seems to me that in order to get actual performance improvement, you'd need to factor out any format analysis done by your customFormatter and formattable arguments into a function that returns some data structure that tells a later formatting call what to do. Then you pull those data structures in your constructor and store them for later use. Presumably this would involve extending ICustomFormatter and IFormattable. Seems kinda unlikely.

提交回复
热议问题