summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_mac.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-06-09 15:34:14 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-06-09 15:34:14 (GMT)
commit628fd7d141013dcda06d13fa644f44029f317a8c (patch)
tree7c75dd78750ecf1d876b6dcedf4a52a354750eee /src/corelib/kernel/qcore_mac.cpp
parentbf540659718c78706622a6cf168387998dd725fd (diff)
downloadQt-628fd7d141013dcda06d13fa644f44029f317a8c.zip
Qt-628fd7d141013dcda06d13fa644f44029f317a8c.tar.gz
Qt-628fd7d141013dcda06d13fa644f44029f317a8c.tar.bz2
get rid of extra copying (another one)
in the static toCFStringRef(const QString &string) method, the string's lifecycle is unkown and thus, to ensure the data consistency, it copies the string's data to the newly created CFStringRef object. but operator CFStringRef() is an other case - here we know that the source string's lifetime is limited by the same QCFString object as the resulting CFStringRef; so, we could use the string's internal buffer as a CFStringRef's one w/o any visible changes (well, except of some speed-up :) ) Merge-request: 2615 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'src/corelib/kernel/qcore_mac.cpp')
-rw-r--r--src/corelib/kernel/qcore_mac.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index e0dae37..80cbac9 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -74,8 +74,13 @@ CFStringRef QCFString::toCFStringRef(const QString &string)
QCFString::operator CFStringRef() const
{
- if (!type)
- const_cast<QCFString*>(this)->type = toCFStringRef(string);
+ if (!type) {
+ const_cast<QCFString*>(this)->type =
+ CFStringCreateWithCharactersNoCopy(0,
+ reinterpret_cast<const UniChar *>(string.unicode()),
+ string.length(),
+ kCFAllocatorNull);
+ }
return type;
}