[rekonq] Websnap::imagePathFromUrl() update proposal

Benjamin Poulain benjamin.poulain at nokia.com
Mon May 31 10:56:03 CEST 2010


>             QStringList toReplace, replacers;
> 
> 
>             toReplace << "%" << "/" << "&" << "," << "+" << "$" << ":"
>         << ";" << "=" << "?" << "@" << "#" << "\\" << "|";
> 
>             replacers << "%25" << "%2F" << "%26" << "%2C" << "%2B" <<
>         "%24" << "%3A" << "%3B" << "%3D" << "%3F" << "%40" << "%23" <<
>         "%5C" << "%7C";
> 
>             while (!(toReplace.empty()) && !(replacers.empty()))
> 
>               name.replace(toReplace.takeFirst(), replacers.takeFirst());

The speed of this code will be O(n*m), n being the size of name, m being 
the size of toReplace. Not worse than the previous code...

If you create a QHash<QChar, QString> to map toReplace to replacers and 
go once over each character of name, replacing each character with the 
hashmap, you get a complexity of O(n). :)

cheers,
Benjamin


More information about the rekonq mailing list