I have a string like the following:
{A}jahshs{b}jwuw{c}wuqjwhaha{d}{e}{f}jsj{g}
And I need to replace every {x}
with a different string. The problem comes because this process will be repeated around 1000 times/second, so I need a optimized/fast way to do it.
Any idea? Boost replace? Boost format? Etc..
preallocate all buffers
....
profit
Oh, and don't spam. Sample code in
510 minutes.Okay here goes: also Live On Coliru
This runs in ~0.239s on my system. Thats about 68k expansions/second.Oops. In release build it does 4 million expansions/second. On Coliru it reaches almost 1 million expansions/second.Room for improvement:
'}'
.