summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfile.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao@trolltech.com>2010-01-07 13:31:08 +0100
committerJoão Abecasis <joao@trolltech.com>2010-01-07 16:33:26 +0100
commit3b57425aa11e5e1536016ccccdde7657493a0dc8 (patch)
treede9b196b7971906c757641903f0ac250ef193687 /src/corelib/io/qfile.cpp
parentce5f772c529517c3e1c043fd826a790316ed9915 (diff)
Avoid double-buffering in QFile
Since Qt 4.3 QIODevice has been providing read buffering for buffered devices; QFile provides a write buffer. Thus, requesting a buffered file from the engine results in unnecessary double-buffering where this is supported natively. By preferring QFile/QIODevice's buffering over the file engine we reduce the number of system calls. On the other hand, buffering inside QIODevice can't easily be disabled without changing the return value of QIODevice::openMode() (function is non-virtual). Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r--src/corelib/io/qfile.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 72d1d16c40..eb6f5be2ce 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -968,9 +968,6 @@ bool QFile::isSequential() const
mode, if the relevant file does not already exist, this function
will try to create a new file before opening it.
- \note Because of limitations in the native API, QFile ignores the
- Unbuffered flag on Windows.
-
\sa QIODevice::OpenMode, setFileName()
*/
bool QFile::open(OpenMode mode)
@@ -988,7 +985,9 @@ bool QFile::open(OpenMode mode)
qWarning("QIODevice::open: File access not specified");
return false;
}
- if (fileEngine()->open(mode)) {
+
+ // QIODevice provides the buffering, so there's no need to request it from the file engine.
+ if (fileEngine()->open(mode | QIODevice::Unbuffered)) {
QIODevice::open(mode);
if (mode & Append)
seek(size());