From 0a6b9df8c8fc8e97ac627081485613e336051208 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 6 Oct 2019 08:10:55 +0200 Subject: convert equals() to operator== in xmlreader::Span Change-Id: Ic6a8eae344c06be87e2bc4bf7f242a2d18ebc8ad Reviewed-on: https://gerrit.libreoffice.org/80312 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/xmlreader/span.hxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'include/xmlreader') diff --git a/include/xmlreader/span.hxx b/include/xmlreader/span.hxx index db0ed229bcd9..038241ef1133 100644 --- a/include/xmlreader/span.hxx +++ b/include/xmlreader/span.hxx @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -50,21 +51,29 @@ struct SAL_WARN_UNUSED OOO_DLLPUBLIC_XMLREADER Span { bool is() const { return begin != nullptr; } - bool equals(Span const & text) const { + bool operator==(Span const & text) const { return length == text.length - && (rtl_str_compare_WithLength( - begin, length, text.begin, text.length) - == 0); + && memcmp(begin, text.begin, text.length) == 0; + } + + bool operator!=(Span const & text) const { + return !(operator==(text)); } bool equals(char const * textBegin, sal_Int32 textLength) const { - return equals(Span(textBegin, textLength)); + return operator==(Span(textBegin, textLength)); + } + + template< std::size_t N > bool operator==(char const (& literal)[N]) + const + { + return operator==(Span(literal, N - 1)); } - template< std::size_t N > bool equals(char const (& literal)[N]) + template< std::size_t N > bool operator!=(char const (& literal)[N]) const { - return equals(Span(literal, N - 1)); + return operator!=(Span(literal, N - 1)); } rtl::OUString convertFromUtf8() const; -- cgit