summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfile.cpp
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-03-08 11:45:05 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-03-13 14:40:50 (GMT)
commita3a2ff59284840f1980197e3f6d06d99fcc0f512 (patch)
tree95226afc1dfb521840e1c7f093ab149aaac85ff4 /src/corelib/io/qfile.cpp
parent5bce44ef030a18d7ed3f6e3abf824d42ab84bf70 (diff)
downloadQt-a3a2ff59284840f1980197e3f6d06d99fcc0f512.zip
Qt-a3a2ff59284840f1980197e3f6d06d99fcc0f512.tar.gz
Qt-a3a2ff59284840f1980197e3f6d06d99fcc0f512.tar.bz2
Optimise QFile::seek that doesn't move the file pointer
If the seek position matches the current file position, then avoid doing an implicit flush that could be expensive. Change-Id: I019858ffb36fe832b9aee8da0a7803cafc8f7f75 Reviewed-by: Jaakko Helanti <ext-jaakko.helanti@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r--src/corelib/io/qfile.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index cfe0700..c8b349a 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1692,6 +1692,9 @@ bool QFile::seek(qint64 off)
return false;
}
+ if (off == d->pos && off == d->devicePos)
+ return true; //avoid expensive flush for NOP seek to current position
+
if (!d->ensureFlushed())
return false;