Delphi StringBuilder

后端 未结 7 1703
别那么骄傲
别那么骄傲 2021-02-12 12:26

Exists in Delphi something like the Java or C# StringBuilder? Or Delphi does not need StringBuilder and s := s + \'some string\'; is good expression (mainly in for,

7条回答
  •  孤独总比滥情好
    2021-02-12 13:07

    I've listed some good resources on Delphi strings below.

    As someone else said, simple concatenation using the '+' operator with the general purpose string types is about as fast as using TStringbuilder (at least for operations of the form: 's := s + [. . . ]'). Don't know if it's true or not, but performance is at least close enough that [1], below, asserts that "Strings concatenation in Delphi is so fast that the new optimized StringBuilder class in Delphi 2009 cannot beat it." This is because the strings are modified in place and Delphi transparenty allocates more memory for the base string if needed, rather than doing a copy-on-write operation of all the data to a new location in memory.

    [1] http://blog.marcocantu.com/blog/delphi_super_duper_strings.html

    [2] http://conferences.codegear.com/he/article/32120

    [3] http://www.codexterity.com/delphistrings.htm

    [4] http://www.monien.net/blog/index.php/2008/10/delphi-2009-tstringbuilder/

提交回复
热议问题