From 00c8e6e60d6f69ec7c9abd14f83dfad4711ce4a4 Mon Sep 17 00:00:00 2001 From: ltrk2 <107155950+ltrk2@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:39:33 -0700 Subject: [PATCH] Use std::string_view instead of strlen --- src/Functions/extractTextFromHTML.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Functions/extractTextFromHTML.cpp b/src/Functions/extractTextFromHTML.cpp index a15611579bb..c7ef97c7bee 100644 --- a/src/Functions/extractTextFromHTML.cpp +++ b/src/Functions/extractTextFromHTML.cpp @@ -70,16 +70,16 @@ namespace ErrorCodes namespace { -inline bool startsWith(const char * s, const char * end, const char * prefix) +bool startsWith(const char * s, const char * end, const std::string_view prefix) { - return s + strlen(prefix) < end && 0 == memcmp(s, prefix, strlen(prefix)); + return s + prefix.length() < end && 0 == memcmp(s, prefix.data(), prefix.length()); } -inline bool checkAndSkip(const char * __restrict & s, const char * end, const char * prefix) +inline bool checkAndSkip(const char * __restrict & s, const char * end, const std::string_view prefix) { if (startsWith(s, end, prefix)) { - s += strlen(prefix); + s += prefix.length(); return true; } return false; @@ -138,7 +138,7 @@ bool processCDATA(const char * __restrict & src, const char * end, char * __rest return true; } -bool processElementAndSkipContent(const char * __restrict & src, const char * end, const char * tag_name) +bool processElementAndSkipContent(const char * __restrict & src, const char * end, const std::string_view tag_name) { const auto * old_src = src;