summaryrefslogtreecommitdiff
path: root/sal/inc/rtl/strbuf.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/strbuf.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/strbuf.hxx')
-rw-r--r--sal/inc/rtl/strbuf.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 7bde9e79b152..945d1d2b179a 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -28,6 +28,10 @@
#include <rtl/string.hxx>
#include <rtl/stringutils.hxx>
+#ifdef RTL_FAST_STRING
+#include <rtl/stringconcat.hxx>
+#endif
+
#ifdef __cplusplus
// The unittest uses slightly different code to help check that the proper
@@ -218,6 +222,20 @@ public:
rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
}
+#ifdef RTL_FAST_STRING
+ template< typename T1, typename T2 >
+ OStringBuffer( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ rtl_String* buffer = NULL;
+ rtl_string_new_WithLength( &buffer, l );
+ char* end = c.addData( buffer->buffer );
+ buffer->length = end - buffer->buffer;
+ pData = buffer;
+ nCapacity = l + 16;
+ }
+#endif
+
/** Assign to this a copy of value.
*/
OStringBuffer& operator = ( const OStringBuffer& value )
@@ -830,6 +848,18 @@ private:
sal_Int32 nCapacity;
};
+#ifdef RTL_FAST_STRING
+template<>
+struct ToStringHelper< OStringBuffer >
+ {
+ static int length( const OStringBuffer& s ) { return s.getLength(); }
+ static char* addData( char* buffer, const OStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
+ static const bool allowOStringConcat = true;
+ static const bool allowOUStringConcat = false;
+ };
+#endif
+
+
}
#ifdef RTL_STRING_UNITTEST