summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-10-17 20:33:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-21 08:36:01 +0200
commit0f874472c672175135520101837ff0c9d4701d7f (patch)
treefa6a504bdfc7d5d838caed7cfb87793321797290 /configmgr
parent9112c18524c9f5e67d6cbb282586a439e3020cdb (diff)
size some stringbuffer to prevent re-alloc
found by the simple expidient of putting asserts in the resize routine. Where an explicit const size is used, I started with 32 and kept doubling until that site did not need resizing anymore. Change-Id: I998787edc940d0a3ba23b5ac37131ab9ecd300f4 Reviewed-on: https://gerrit.libreoffice.org/81138 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/childaccess.cxx2
-rw-r--r--configmgr/source/data.cxx7
-rw-r--r--configmgr/source/xcsparser.cxx2
-rw-r--r--configmgr/source/xcuparser.cxx2
4 files changed, 7 insertions, 6 deletions
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 82ca003c1703..68bc0b01351c 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -104,7 +104,7 @@ std::vector<OUString> ChildAccess::getRelativePath() {
}
OUString ChildAccess::getRelativePathRepresentation() {
- OUStringBuffer path;
+ OUStringBuffer path(128);
rtl::Reference< Access > parent(getParentAccess());
if (parent.is()) {
path.append(parent->getRelativePathRepresentation());
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 7ff344650ebc..4f91d3b25612 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -49,7 +49,7 @@ bool decode(
assert(
begin >= 0 && begin <= end && end <= encoded.getLength() &&
decoded != nullptr);
- OUStringBuffer buf;
+ OUStringBuffer buf(end - begin);
while (begin != end) {
sal_Unicode c = encoded[begin++];
if (c == '&') {
@@ -82,7 +82,8 @@ OUString Data::createSegment(
if (templateName.isEmpty()) {
return name;
}
- OUStringBuffer buf(templateName);
+ OUStringBuffer buf(128);
+ buf.append(templateName);
//TODO: verify template name contains no bad chars?
buf.append("['");
for (sal_Int32 i = 0; i < name.getLength(); ++i) {
@@ -207,7 +208,7 @@ rtl::Reference< Node > Data::resolvePathRepresentation(
}
NodeMap const & components = getComponents();
NodeMap::const_iterator i(components.find(seg));
- OUStringBuffer canonic;
+ OUStringBuffer canonic(128);
rtl::Reference< Node > parent;
int finalized = NO_LAYER;
for (rtl::Reference< Node > p(i == components.end() ? nullptr : i->second);;) {
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 24e1dc008312..c0b34974157b 100644
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -321,7 +321,7 @@ void XcsParser::characters(xmlreader::Span const & text) {
void XcsParser::handleComponentSchema(xmlreader::XmlReader & reader) {
//TODO: oor:version, xml:lang attributes
- OStringBuffer buf;
+ OStringBuffer buf(256);
buf.append('.');
bool hasPackage = false;
bool hasName = false;
diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx
index 89508be97992..03e3c60ab067 100644
--- a/configmgr/source/xcuparser.cxx
+++ b/configmgr/source/xcuparser.cxx
@@ -220,7 +220,7 @@ XcuParser::Operation XcuParser::parseOperation(xmlreader::Span const & text) {
}
void XcuParser::handleComponentData(xmlreader::XmlReader & reader) {
- OStringBuffer buf;
+ OStringBuffer buf(256);
buf.append('.');
bool hasPackage = false;
bool hasName = false;