[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/document: refactor mimetype detection code even more, no qstring construction, jus
From: Christoph Cullmann <cullmann () kde ! org>
Date: 2016-09-06 20:51:02
Message-ID: E1bhNKg-0005nZ-WA () code ! kde ! org
[Download RAW message or body]
Git commit 54473d689e6e0725b7fd7934e2a54262daa3e0fe by Christoph Cullmann.
Committed on 06/09/2016 at 20:50.
Pushed by cullmann into branch 'master'.
refactor mimetype detection code even more, no qstring construction, just append the \
two things in two pieces, better guard, no break
M +3 -7 src/document/katedocument.cpp
http://commits.kde.org/ktexteditor/54473d689e6e0725b7fd7934e2a54262daa3e0fe
diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp
index 93c3bb1..8b6a127 100644
--- a/src/document/katedocument.cpp
+++ b/src/document/katedocument.cpp
@@ -2123,14 +2123,10 @@ QString KTextEditor::DocumentPrivate::mimeType()
* collect first 4k of text
* only heuristic
*/
- const uint limit = 4096;
QByteArray buf;
- for (int i = 0; i < lines(); ++i) {
- const QString ld(line(i) + QLatin1Char('\n'));
- buf.append(ld.toUtf8());
- if (buf.size() >= limit) {
- break;
- }
+ for (int i = 0; (i < lines()) && (buf.size() <= 4096); ++i) {
+ buf.append(line(i).toUtf8());
+ buf.append('\n');
}
// use path of url, too, if set
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic