From 49e804ec79b56bb107fedbeb6b47493e2401635e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 30 Jul 2023 12:08:32 +0100 Subject: Inline functions for removing trailing/leading chars --- icespider/core/util.cpp | 16 ---------------- icespider/core/util.h | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/icespider/core/util.cpp b/icespider/core/util.cpp index b330f79..5e51b8b 100644 --- a/icespider/core/util.cpp +++ b/icespider/core/util.cpp @@ -7,20 +7,4 @@ namespace IceSpider { { throw Http400_BadRequest(); } - - void - remove_trailing(std::string_view & in, const char c) - { - if (const auto n = in.find_last_not_of(c); n != std::string_view::npos) { - in.remove_suffix(in.length() - n - 1); - } - } - - void - remove_leading(std::string_view & in, const char c) - { - if (const auto n = in.find_first_not_of(c); n != std::string_view::npos) { - in.remove_prefix(n); - } - } } diff --git a/icespider/core/util.h b/icespider/core/util.h index f4868c3..ecf0831 100644 --- a/icespider/core/util.h +++ b/icespider/core/util.h @@ -161,6 +161,19 @@ namespace IceSpider { } } - void remove_trailing(std::string_view & in, const char c); - void remove_leading(std::string_view & in, const char c); + inline void + remove_trailing(std::string_view & in, const char c) + { + if (const auto n = in.find_last_not_of(c); n != std::string_view::npos) { + in.remove_suffix(in.length() - n - 1); + } + } + + inline void + remove_leading(std::string_view & in, const char c) + { + if (const auto n = in.find_first_not_of(c); n != std::string_view::npos) { + in.remove_prefix(n); + } + } } -- cgit v1.2.3