Update git submodules
[LibreOffice.git] / external / librevenge / tdf63130-improve-perf.patch.0
blob02a8a6e1f94b74c118b36cc71f89f43582dc93ee
1 --- inc/librevenge/RVNGString.h 2023-05-17 15:48:15.373159469 +0200
2 +++ inc/librevenge/RVNGString.h 2023-05-17 15:49:00.781411917 +0200
3 @@ -22,6 +22,7 @@
4  #define RVNGSTRING_H
5  
6  #include "librevenge-api.h"
7 +#include <string>
8  
9  namespace librevenge
10  {
11 @@ -36,6 +37,7 @@
12         RVNGString();
13         RVNGString(const RVNGString &other);
14         RVNGString(const char *str);
15 +       RVNGString(std::string&&);
16         ~RVNGString();
18         /** Create a new string from \a s as escaped XML.
19 --- src/lib/RVNGBinaryData.cpp  2023-05-17 15:48:15.373159469 +0200
20 +++ src/lib/RVNGBinaryData.cpp  2023-05-17 15:49:00.773411873 +0200
21 @@ -67,9 +67,9 @@
22         boost::archive::iterators::transform_width<std::vector<unsigned char>::const_iterator, 6, 8 > > base64_encoder;
24         // Encode the buffer and create a string
25 -       std::copy(
26 +       result.insert(result.begin(),
27             base64_encoder(source.begin()),
28 -           base64_encoder(source.end()), std::back_inserter(result));
29 +           base64_encoder(source.end()));
31         result.append(numPadding, '=');  // add '=' for each padded character
32  }
33 @@ -150,10 +150,10 @@
34  {
35         m_binaryDataImpl->makeUnique();
37 -       unsigned long previousSize = m_binaryDataImpl->m_ptr->m_buf.size();
38 -       m_binaryDataImpl->m_ptr->m_buf.reserve(previousSize + data.m_binaryDataImpl->m_ptr->m_buf.size());
39 -       for (unsigned long i = 0; i < data.m_binaryDataImpl->m_ptr->m_buf.size(); i++)
40 -               m_binaryDataImpl->m_ptr->m_buf.push_back(data.m_binaryDataImpl->m_ptr->m_buf[i]);
41 +       m_binaryDataImpl->m_ptr->m_buf.insert(
42 +               m_binaryDataImpl->m_ptr->m_buf.end(),
43 +               data.m_binaryDataImpl->m_ptr->m_buf.begin(),
44 +               data.m_binaryDataImpl->m_ptr->m_buf.end());
45  }
47  void RVNGBinaryData::appendBase64Data(const RVNGString &base64)
48 @@ -231,8 +231,9 @@
49  const RVNGString RVNGBinaryData::getBase64Data() const
50  {
51         std::string base64;
52 +       base64.reserve(m_binaryDataImpl->m_ptr->m_buf.size() / 4 * 3);
53         convertToBase64(base64, m_binaryDataImpl->m_ptr->m_buf);
54 -       return RVNGString(base64.c_str());
55 +       return RVNGString(std::move(base64));
56  }
58  RVNGInputStream *RVNGBinaryData::getDataStream() const
59 --- src/lib/RVNGString.cpp      2023-05-17 15:48:15.373159469 +0200
60 +++ src/lib/RVNGString.cpp      2023-05-17 15:49:00.773411873 +0200
61 @@ -73,6 +73,7 @@
62  {
63  public:
64         RVNGStringImpl() : m_buf() {}
65 +       RVNGStringImpl(std::string&& str) : m_buf(std::move(str)) {}
66         bool empty() const
67         {
68                 return m_buf.empty();
69 @@ -157,6 +158,11 @@
70                 m_stringImpl->m_buf = str;
71  }
73 +RVNGString::RVNGString(std::string&& str) :
74 +       m_stringImpl(new RVNGStringImpl(std::move(str)))
78  RVNGString RVNGString::escapeXML(const RVNGString &s)
79  {
80         RVNGString escaped;