From 2f5f45921b05904a4be1ff633be09c62cb44ff08 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 13 Sep 2019 15:13:55 +0200 Subject: support O(U)String::number() for fast string concatenation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When I did the fast string concatenation, I didn't add any support for number(), which simply returned a O(U)String, and so it did the extra allocation/deallocation, although that could be avoided. In order to support this, number() now returns a special temporary return type, similarly to O(U)StringConcat, which allows delaying the concatenation the same way. Also similarly, the change of the return type in some cases requires explicit cast to the actual string type. Usage of OString::getStr() is so extensive in the codebase that I actually added it to the helper class, after that it's only relatively few cases. Change-Id: Iba6e158010e1e458089698c426803052b6f46031 Reviewed-on: https://gerrit.libreoffice.org/78873 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- include/com/sun/star/uno/Any.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/com') diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx index d7b3420baecc..05f032fc5b81 100644 --- a/include/com/sun/star/uno/Any.hxx +++ b/include/com/sun/star/uno/Any.hxx @@ -249,6 +249,14 @@ template Any toAny(rtl::OUStringConcat && value) { return makeAny(std::move(value)); } +template +Any makeAny(rtl::OUStringNumber && value) +{ return Any(OUString(std::move(value))); } + +template +Any toAny(rtl::OUStringNumber && value) +{ return makeAny(std::move(value)); } + template bool fromAny(Any const & any, T * value) { assert(value != nullptr); return any >>= *value; @@ -295,6 +303,17 @@ inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& } template void operator <<=(Any &, rtl::OUStringConcat const &) = delete; +template< class C > +inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value ) +{ + const rtl::OUString str( std::move(value) ); + const Type & rType = ::cppu::getTypeFavourUnsigned(&str); + ::uno_type_any_assign( + &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(), + cpp_acquire, cpp_release ); +} +template +void operator <<=(Any &, rtl::OUStringNumber const &) = delete; #endif #if defined LIBO_INTERNAL_ONLY -- cgit