summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qtextstream.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-07-18 10:54:38 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-07-19 07:54:36 +0200
commit6fa8db333d24f8c250b4b5656682e22ba586c81c (patch)
tree8163944fb6a92cea1246f760cd8655b154a369f8 /src/corelib/serialization/qtextstream.cpp
parenta9f252cc44127d1dfcd71ea851b0a4095873b7f9 (diff)
QTextStream: Extract Method writeImpl() from write() overloads
They're all the same, except the type of the thing being append()ed to one of the two QStrings, so make the actual implementation a template. Task-number: QTBUG-138520 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I0a3041984b690cc0febac932b53bd6ec601e8780 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qtextstream.cpp')
-rw-r--r--src/corelib/serialization/qtextstream.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 061b39d1fb8..44eb86fad84 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -696,7 +696,8 @@ inline void QTextStreamPrivate::restoreToSavedConverterState()
/*!
\internal
*/
-void QTextStreamPrivate::write(QStringView s)
+template <typename Appendable>
+void QTextStreamPrivate::writeImpl(Appendable s)
{
if (string) {
// ### What about seek()??
@@ -711,16 +712,17 @@ void QTextStreamPrivate::write(QStringView s)
/*!
\internal
*/
+void QTextStreamPrivate::write(QStringView s)
+{
+ writeImpl(s);
+}
+
+/*!
+ \internal
+*/
void QTextStreamPrivate::write(QChar ch)
{
- if (string) {
- // ### What about seek()??
- string->append(ch);
- } else {
- writeBuffer += ch;
- if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE)
- flushWriteBuffer();
- }
+ writeImpl(ch);
}
/*!
@@ -728,14 +730,7 @@ void QTextStreamPrivate::write(QChar ch)
*/
void QTextStreamPrivate::write(QLatin1StringView data)
{
- if (string) {
- // ### What about seek()??
- string->append(data);
- } else {
- writeBuffer += data;
- if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE)
- flushWriteBuffer();
- }
+ writeImpl(data);
}
/*!