[PATCH 9/9] Don't check if a file exists right before trying to open it

Thiago Macieira thiago at macieira.org
Wed Dec 11 17:56:35 UTC 2013


The open call will tell us what we need to know. Obviously we can't open
a file that doesn't exist. This saves us one stat() or Windows
equivalent.

Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
 qt-ui/subsurfacewebservices.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 7828b40..b6d9261 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -559,8 +559,7 @@ void DivelogsDeWebServices::prepareDivesForUpload()
 	char *filename = prepare_dives_for_divelogs(true);
 	if (filename) {
 		QFile f(filename);
-		if (f.exists()) {
-			f.open(QIODevice::ReadOnly);
+		if (f.open(QIODevice::ReadOnly)) {
 			uploadDives((QIODevice *)&f);
 			f.close();
 			f.remove();
-- 
1.7.11.7



More information about the subsurface mailing list