D5707: Normalize line endings when creating ParseJob from background file.
Milian Wolff
noreply at phabricator.kde.org
Sun May 14 10:33:22 UTC 2017
mwolff requested changes to this revision.
mwolff added a comment.
This revision now requires changes to proceed.
Sorry, but I'm against pushing it as-is. Doing the optimization isn't hard, you are more or less prematurely pessimizing it here. And if you want to put this into anything but master, having a proper unit test is a must anyways I'd say.
So, please if at all possible at least write a unit test. And then use something like this instead of the two replace calls (untested):
QByteArray normalizeLineEndings(QByteArray text)
{
for (int i = 0, s = text.size(); i < s; ++i) {
if (text[i] != '\r') {
continue;
} else if (i + 1 < s && text[i + 1] == '\n') {
text.remove(i, 1);
} else {
text[i] = '\n';
}
}
return text;
}
Note that by making it a free function in some util header, we can properly unit test it.
INLINE COMMENTS
> parsejob.cpp:82
>
> + void normalizeLineEndings() {
> + // TODO: Optimization, could do this in one pass.
put the { on its own line
REPOSITORY
R33 KDevPlatform
REVISION DETAIL
https://phabricator.kde.org/D5707
To: flherne, brauch, #kdevelop, mwolff
Cc: nalvarez, mwolff, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170514/58e93729/attachment-0001.html>
More information about the KDevelop-devel
mailing list