Re:Performance Improvement with the StringBuilder for C++
by gngeal on Friday September 06, 2013 @10:37AM
(#6340637)
String concatenation? Are we living in the 1980's? What about string trees? These problems can be solved simply using a proper data structure. Concatenation, insertion, deletion etc. should be almost constant-time operations.
[ Parent
| on HN ]
Re:Performance Improvement with the StringBuilder for C++
by alayne on Friday September 06, 2013 @10:39AM
(#6340643)
Data structures like ropes are really more for editing than concatenation.
Re:Performance Improvement with the StringBuilder for C++
by phaemon on Friday September 06, 2013 @11:29AM
(#6340897)
I'd never heard of "ropes" in that context and read that as the worst simile ever ("Data structures, like ropes, are...")
Re:Performance Improvement with the StringBuilder for C++
by lucian1900 on Friday September 06, 2013 @11:26AM
(#6340883)
Trees (like the ropes you might use in this case) are not necessarily faster on modern CPUs. Caches and branch prediction tend to dominate performance in such cases.
Re:Performance Improvement with the StringBuilder for C++
by gngeal on Friday September 06, 2013 @02:49PM
(#6341997)
I don't see how branch prediction and caches could dominate performance of logically concatenating a huge amount of text instead of doing it physically.
Re:Performance Improvement with the StringBuilder for C++
by dkersten on Friday September 06, 2013 @03:16PM
(#6342119)
I guess it depends on what other operations you need. If the only operation you need is concatenation then trees are definitely faster. Otherwise it depends.
Re:Performance Improvement with the StringBuilder for C++
by lucian1900 on Saturday September 07, 2013 @01:45PM
(#6345789)
Arrays and copies are often faster than the equivalent structure-sharing trees, under a certain size at least.