summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qtextstream_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-15 03:36:22 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-10-23 05:51:00 +0000
commit8515aa18716779985a5955292524fd683528c576 (patch)
tree35a1312c967a5ffcdc4e8f02c1f3afee5bb637a9 /src/corelib/io/qtextstream_p.h
parentbe926e412c9c4ec9ee77b49dbe370fbb5451f0e1 (diff)
QTextStream: optimize streaming of QLatin1String and const char*
Instead of converting the QLatin1String to a QString at the first opportunity, keep it around until it is appended to one of the internal QStrings in write(). Avoids a memory allocation per QLatin1String / const char* streamed. Change-Id: Id973a9b743e5a6696defbc4ef4ed2db1ef54e9cc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qtextstream_p.h')
-rw-r--r--src/corelib/io/qtextstream_p.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qtextstream_p.h b/src/corelib/io/qtextstream_p.h
index c44ae5dada..115408a6dd 100644
--- a/src/corelib/io/qtextstream_p.h
+++ b/src/corelib/io/qtextstream_p.h
@@ -168,15 +168,17 @@ public:
inline void write(const QString &data) { write(data.begin(), data.length()); }
inline void write(QChar ch);
void write(const QChar *data, int len);
+ void write(QLatin1String data);
inline void putString(const QString &ch, bool number = false) { putString(ch.constData(), ch.length(), number); }
void putString(const QChar *data, int len, bool number = false);
+ void putString(QLatin1String data, bool number = false);
inline void putChar(QChar ch);
void putNumber(qulonglong number, bool negative);
struct PaddingResult {
enum { PreallocatedPadding = 80 }; // typical line length
- int right, left;
+ int left, right;
QVarLengthArray<QChar, PreallocatedPadding> padding;
};
PaddingResult padding(int len) const;