Michael Matz napsal(a):
Hi,
On Tue, 22 Apr 2008, Josef Reidinger wrote:
gsub is slower. That's also expected, as it needs to copy the whole string.
Ciao, Michael. I post it in another note about performance of different string size to replace, which I before forget send. In zypper is replaced '\n' for some ' ' (not exactly set how many).
testcase when to and from have different size: zypper gsub boost user time: 817 system time: 1 jano replace_all boost user time: 830 system time: 0
I think that's just an artifact. gsub and replace_all use mostly the same inner loop, on the same inputs: one .find call, one .replace call. gsub just also hoisted the constant length arguments out of the loop body. So gsub does strictly more work than replace_all (the string copy).
Ciao, Michael.
Interesting, I think gsub works little different so I try implement little different version. Problem with replace on string with different length of substitute is that each call must move some char in internall char strorage...so if gsub instead of replacing append can be better...something like 'non-matching string'+s/from/to/+'another non-matching'...appending can have better performance because doesn't need moving with internal characters like if you change 2char for one, then every characters after this occurence must be moved to left by one. I test it on Thursday or Friday and write here result. Pepa -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org