diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-14 15:59:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-14 21:31:04 +0200 |
commit | 233fa432256603812454cbdc372059afade50942 (patch) | |
tree | b78efd6117f515057412aafe1f72f57caa1c3912 /xmlreader | |
parent | 46d3e84d7a131f7c72cb536ab2f314cb55ffc155 (diff) |
Revert "improve perf of xmlreader::Pad"
This reverts commit de5af8315e014ce3408f66c6de3c9c4e841f8437.
Reason for revert: this commit needs bounds checking before it can reland
Change-Id: I686a533cc27fc4644cce918ca64bd168bba19617
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115518
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlreader')
-rw-r--r-- | xmlreader/source/pad.cxx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/xmlreader/source/pad.cxx b/xmlreader/source/pad.cxx index 74bb5ec63fb0..ce45f805f496 100644 --- a/xmlreader/source/pad.cxx +++ b/xmlreader/source/pad.cxx @@ -29,49 +29,46 @@ namespace xmlreader { void Pad::add(char const * begin, sal_Int32 length) { assert( - begin != nullptr && length >= 0 && !(span_.is() && buflength_ != 0)); + begin != nullptr && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); if (length != 0) { flushSpan(); - if (buflength_ == 0) { + if (buffer_.isEmpty()) { span_ = Span(begin, length); } else { - memcpy(buffer_ + buflength_, begin, length); - buflength_ += length; + buffer_.append(begin, length); } } } void Pad::addEphemeral(char const * begin, sal_Int32 length) { assert( - begin != nullptr && length >= 0 && !(span_.is() && buflength_ != 0)); + begin != nullptr && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); if (length != 0) { flushSpan(); - memcpy(buffer_ + buflength_, begin, length); - buflength_ += length; + buffer_.append(begin, length); } } void Pad::clear() { - assert(!(span_.is() && buflength_ != 0)); + assert(!(span_.is() && buffer_.getLength() != 0)); span_.clear(); - buflength_ = 0; + buffer_.setLength(0); } Span Pad::get() const { - assert(!(span_.is() && buflength_ != 0)); + assert(!(span_.is() && buffer_.getLength() != 0)); if (span_.is()) { return span_; - } else if (buflength_ == 0) { + } else if (buffer_.isEmpty()) { return Span(""); } else { - return Span(buffer_, buflength_); + return Span(buffer_.getStr(), buffer_.getLength()); } } void Pad::flushSpan() { if (span_.is()) { - memcpy(buffer_ + buflength_, span_.begin, span_.length); - buflength_ += span_.length; + buffer_.append(span_.begin, span_.length); span_.clear(); } } |