Skip to content
Discussion options

You must be logged in to vote

There is not something currently in the standard library that acts like a string buffer, but I think the regular string functions are pretty performant for most use cases currently. I believe they try to realloc before mallocing new memory for most operations, which saves time for copying and allocation. join for example iterates over the list, calculating the total size before allocating space for the new string.

As a general rule working with string will be much faster than converting between strings and list<char>, at least when you are working with large strings.

With string building I would expect that list<string> would be fastest, with a final join().

Yes, the list<char> will be ta…

Replies: 6 comments 17 replies

Comment options

You must be logged in to vote
4 replies
@timbertson
Comment options

@timbertson
Comment options

@JanBeh
Comment options

@TimWhiting
Comment options

Answer selected by JanBeh
Comment options

You must be logged in to vote
1 reply
@TimWhiting
Comment options

Comment options

You must be logged in to vote
1 reply
@TimWhiting
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@TimWhiting
Comment options

@JanBeh
Comment options

Comment options

You must be logged in to vote
9 replies
@TimWhiting
Comment options

@JanBeh
Comment options

@TimWhiting
Comment options

@TimWhiting
Comment options

@TimWhiting
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants