diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2019-10-06 08:10:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-06 17:06:53 +0200 |
commit | 0a6b9df8c8fc8e97ac627081485613e336051208 (patch) | |
tree | 1387d9751601052546c2eeb5af037429718f8aac /include/xmlreader/span.hxx | |
parent | 3e5d4ecbde512efe169536544489635f7f076fd2 (diff) |
convert equals() to operator== in xmlreader::Span
Change-Id: Ic6a8eae344c06be87e2bc4bf7f242a2d18ebc8ad
Reviewed-on: https://gerrit.libreoffice.org/80312
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/xmlreader/span.hxx')
-rw-r--r-- | include/xmlreader/span.hxx | 23 |
1 files changed, 16 insertions, 7 deletions
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 <sal/config.h> #include <cstddef> +#include <cstring> #include <sal/types.h> #include <rtl/string.h> @@ -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; |