Mailinglist Archive: zypp-devel (226 mails)
| < Previous | Next > |
Re: [zypp-devel] Re: [zypp-commit] r9774 - /trunk/zypper/src/zypper-utils.cc
- From: josef reidiner <jreidinger@xxxxxxx>
- Date: Wed, 23 Apr 2008 19:47:06 +0200
- Message-id: <480F761A.7030705@xxxxxxx>
Michael Matz napsal(a):
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@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
Hi,
On Tue, 22 Apr 2008, Josef Reidinger wrote:
gsub is slower. That's also expected, as it needs to copy the whole string.I post it in another note about performance of different string size to
Ciao,
Michael.
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@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |