diff options
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(); } } |