summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-03-08 11:45:05 +0000
committerQt by Nokia <qt-info@nokia.com>2012-03-13 15:40:50 +0100
commita3a2ff59284840f1980197e3f6d06d99fcc0f512 (patch)
tree95226afc1dfb521840e1c7f093ab149aaac85ff4 /src/corelib/io
parent5bce44ef030a18d7ed3f6e3abf824d42ab84bf70 (diff)
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')
-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 cfe0700e7b..c8b349a52d 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;