Error when calling Amarok::decapitateString()

Pavel Shved pavel.shved at gmail.com
Fri Jan 9 03:54:44 UTC 2009


Nicholas Sinlock wrote:
> I kinda like it.  I see a few things about it though.   First, even if 
> the reference string is the exact common prefix, you'll still
> step through the entire length.
Yes.  No algorithm would never step through entire its length.  How are 
we supposed to compare it otherwise?  Or you think that startsWith() 
function doesn't step through its length?

> Second it doesn't do anything about 
> extraneous symbols or white space in the "clean" string
> after the common prefix is removed, which I think might be useful 
> considering it's application and that it is a Amarok specific function.

The QString::trimmed(), that _is_ called in my code unconditionally, 
removes spaces from beginning and end of string, if there are any.  Just 
add another QString function (like `simplify' or something, i don't 
remember its name) to trim all unnecessary whitespace--if it's what's 
really intended.

<...>

> Lemme know what you think...

I think, that

a) your solution is even longer, more ineffective and much more obscure 
than the original one;
b) your solution doesn't pass cases #4 and 5 from my little test, 
causing a segfault at the latter;
c) there's too much debate for such a small function :-)



More information about the Amarok mailing list