> 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 _______________________________________________ rekonq mailing list [email protected] https://mail.kde.org/mailman/listinfo/rekonq
