Avoid spurious detaching in QDir::to/fromNativeSeparators
authorJoão Abecasis <joao.abecasis@nokia.com>
Fri, 5 Aug 2011 08:40:46 +0000 (10:40 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 20 Oct 2011 14:52:38 +0000 (16:52 +0200)
commitb0a6caf84b0a674aaeb4dd5308d980911a8b1ff2
tree1893aa797acd0334f4bb286e83869ba5325e2285
parent0e7cecb861c7be73d3ef46b41ad6d1a5691b5e7d
Avoid spurious detaching in QDir::to/fromNativeSeparators

The new code avoids non-const detaching operations until needed and uses
a pointer into the "raw" QChar data from then on, thus skipping unneeded
checks on the reference count for further detaching.

These functions are used all the time by the file system classes so this
small optimization won't hurt. In particular, it will help users who
already use '/' when passing paths into Qt.

Reviewed-by: Peter Hartmann
(cherry picked from commit 773a6df46243831dee7559f90e33d7eff3c5c71e)

Change-Id: I27787e787b544a63c9ea1e4138bd548500104dff
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
src/corelib/io/qdir.cpp