[Haskell-cafe] Efficient string construction
ekmett at gmail.com
Thu Jun 3 13:10:30 EDT 2010
You might also look at Data.Rope from the rope library, which provides an
O(1) append for strict bytestring chunks, and the ability to decode UTF-8
chars from the result.
I'd also be happy to work with you if the current API falls short of your
On Thu, Jun 3, 2010 at 10:03 AM, Kevin Jardine <kevinjardine at yahoo.com>wrote:
> (I've done a basic Google search on this with no results. Apologies if this
> has been asked before.)
> I am coding a web application in which the content is a Unicode string
> built up over multiple functions and maintained in a State structure.
> I gather that the String module is inefficient and that Data.Text would be
> a better choice.
> Is it more efficient to build up a list of Text objects over time and
> combine them together with a single Data.Text.concat for the final output or
> to run Data.Text.append for each new string so that I am maintaining a
> single Text object rather than a list?
> As Data.Text.append requires copying both strings each time, my gut feeling
> is that concat would be much more efficient, but Haskell has surprised me
> before, so I wanted to check.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe