[Libreoffice-commits] .: sal/inc
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Jan 19 06:03:33 PST 2013
sal/inc/rtl/string.hxx | 10 ++++++++--
sal/inc/rtl/ustring.hxx | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
New commits:
commit 06e76156d2ea1ce8a112f9e2312d6074478de648
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Sat Jan 19 13:54:40 2013 +0100
microoptimization for "" OUString ctor
Now 'OUString()' and '""' should be exactly the same, and thus the latter better :).
Change-Id: If42b2ca5889967aaa8ccdaf531b45c75c12d54fd
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 6b3d2ff..11a7bf7 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 a4051ac..69b8ab8 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;
}
More information about the Libreoffice-commits
mailing list