diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-01-19 13:54:40 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-01-19 15:03:11 +0100 |
commit | 06e76156d2ea1ce8a112f9e2312d6074478de648 (patch) | |
tree | ed6beb5c703066db0584cabed8ab07800d123b76 /sal/inc | |
parent | bae655a7c2c5bb7e612b068eea34ec5780c58513 (diff) |
microoptimization for "" OUString ctor
Now 'OUString()' and '""' should be exactly the same, and thus the latter better :).
Change-Id: If42b2ca5889967aaa8ccdaf531b45c75c12d54fd
Diffstat (limited to 'sal/inc')
-rw-r--r-- | sal/inc/rtl/string.hxx | 10 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 6b3d2fff877a..11a7bf787853 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -205,7 +205,10 @@ public: { assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); pData = 0; - rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); + if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string + rtl_string_new( &pData ); + else + rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); #ifdef RTL_STRING_UNITTEST rtl_string_unittest_const_literal = true; #endif @@ -304,7 +307,10 @@ public: { RTL_STRING_CONST_FUNCTION assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); - rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); + if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string + rtl_string_new( &pData ); + else + rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); return *this; } diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index a4051ac928e4..69b8ab863bfa 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -231,7 +231,10 @@ public: { assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); pData = 0; - rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); + if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string + rtl_uString_new( &pData ); + else + rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); #ifdef RTL_STRING_UNITTEST rtl_string_unittest_const_literal = true; #endif @@ -393,7 +396,10 @@ public: typename internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal ) { assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); - rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); + if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string + rtl_uString_new( &pData ); + else + rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 ); return *this; } |