From 628fd7d141013dcda06d13fa644f44029f317a8c Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:14 +0200 Subject: 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 --- src/corelib/kernel/qcore_mac.cpp | 9 +++++++-- 1 file 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(this)->type = toCFStringRef(string); + if (!type) { + const_cast(this)->type = + CFStringCreateWithCharactersNoCopy(0, + reinterpret_cast(string.unicode()), + string.length(), + kCFAllocatorNull); + } return type; } -- cgit v0.12