summaryrefslogtreecommitdiff
path: root/sal/inc/rtl/ustrbuf.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-12-02 22:29:21 +0100
committerLuboš Luňák <l.lunak@suse.cz>2012-12-03 18:04:23 +0100
commitd87f5d30879aca73fff271c254589fc41a91fdd0 (patch)
treed3d736178035c1d590f0642cd031e1f6d4b3fd17 /sal/inc/rtl/ustrbuf.hxx
parent86a53cea0f9066d347cf802f4470ebaef9a5434a (diff)
support for fast O(U)String concatenation using operator+
Operator+ now, instead of requiring O(U)String operands and returning another O(U)String object, keeps a track of the whole concatenation operation using temporary O(U)StringConcat objects and performs the whole operation only at the very end. Change-Id: I94b3348300a137498514d26e96459c1698328520
Diffstat (limited to 'sal/inc/rtl/ustrbuf.hxx')
-rw-r--r--sal/inc/rtl/ustrbuf.hxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 6338dd1a81cb..7d36356cd404 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -29,6 +29,10 @@
#include <rtl/ustring.hxx>
#include <rtl/stringutils.hxx>
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
// The unittest uses slightly different code to help check that the proper
// calls are made. The class is put into a different namespace to make
// sure the compiler generates a different (if generating also non-inline)
@@ -209,6 +213,20 @@ public:
}
#endif
+#ifdef RTL_FAST_STRING
+ template< typename T1, typename T2 >
+ OUStringBuffer( const OUStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ rtl_uString* buffer = NULL;
+ rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary
+ sal_Unicode* end = c.addData( buffer->buffer );
+ buffer->length = end - buffer->buffer;
+ // TODO realloc in case buffer->length is noticeably smaller than l ?
+ pData = buffer;
+ nCapacity = l + 16;
+ }
+#endif
/** Assign to this a copy of value.
*/
OUStringBuffer& operator = ( const OUStringBuffer& value )
@@ -1223,6 +1241,17 @@ private:
sal_Int32 nCapacity;
};
+#ifdef RTL_FAST_STRING
+template<>
+struct ToStringHelper< OUStringBuffer >
+ {
+ static int length( const OUStringBuffer& s ) { return s.getLength(); }
+ static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = false;
+ static const bool allowOUStringConcat = true;
+ };
+#endif
+
}
#ifdef RTL_STRING_UNITTEST