common/Message.hpp | 8 ++++---- common/StringVector.hpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
New commits: commit f7d42c045ab1e52c9eaa6f4aa0ce7ed910b026c5 Author: Ashod Nakashian <[email protected]> AuthorDate: Wed Jun 3 17:54:57 2020 -0400 Commit: Ashod Nakashian <[email protected]> CommitDate: Tue Jun 23 06:42:25 2020 +0200 wsd: use more efficient StringVector::equals Change-Id: Ib9a431fa5f8ba95a2ef76baca22b05ed28ebad79 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96377 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Ashod Nakashian <[email protected]> diff --git a/common/Message.hpp b/common/Message.hpp index 7bbadd172..c02625dfb 100644 --- a/common/Message.hpp +++ b/common/Message.hpp @@ -140,10 +140,10 @@ private: Type detectType() const { - if (_tokens[0] == "tile:" || - _tokens[0] == "tilecombine:" || - _tokens[0] == "renderfont:" || - _tokens[0] == "windowpaint:") + if (_tokens.equals(0, "tile:") || + _tokens.equals(0, "tilecombine:") || + _tokens.equals(0, "renderfont:") || + _tokens.equals(0, "windowpaint:")) { return Type::Binary; } diff --git a/common/StringVector.hpp b/common/StringVector.hpp index f995c0b0f..c414beb4f 100644 --- a/common/StringVector.hpp +++ b/common/StringVector.hpp @@ -125,6 +125,19 @@ public: return _string.compare(token._index, token._length, string) == 0; } + /// Compares the nth token with string. + template <std::size_t N> + bool equals(std::size_t index, const char (&string)[N]) const + { + if (index >= _tokens.size()) + { + return false; + } + + const StringToken& token = _tokens[index]; + return _string.compare(token._index, token._length, string, N) == 0; + } + /// Compares the nth token with the mth token from an other StringVector. bool equals(std::size_t index, const StringVector& other, std::size_t otherIndex); }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
