[PATCH v2 1/2] libcamera: utils: StringSplitter: Inline some trivial methods
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Dec 5 21:25:09 CET 2024
Hi Barnabás,
Thank you for the patch.
On Thu, Dec 05, 2024 at 09:23:00AM +0000, Barnabás Pőcze wrote:
> Inline some of the more trivial methods so that they can
> be inlined by the compiler.
>
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> include/libcamera/base/utils.h | 17 ++++++++++++++---
> src/libcamera/base/utils.cpp | 15 ---------------
> 2 files changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
> index 957150cb..c4a06660 100644
> --- a/include/libcamera/base/utils.h
> +++ b/include/libcamera/base/utils.h
> @@ -204,7 +204,11 @@ public:
>
> iterator &operator++();
> std::string operator*() const;
> - bool operator!=(const iterator &other) const;
> +
> + bool operator!=(const iterator &other) const
> + {
> + return pos_ != other.pos_;
> + }
>
> private:
> const StringSplitter *ss_;
> @@ -212,8 +216,15 @@ public:
> std::string::size_type next_;
> };
>
> - iterator begin() const;
> - iterator end() const;
> + iterator begin() const
> + {
> + return { this, 0 };
> + }
> +
> + iterator end() const
> + {
> + return { this, std::string::npos };
> + }
>
> private:
> std::string str_;
> diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp
> index 67e5a896..bcfc1941 100644
> --- a/src/libcamera/base/utils.cpp
> +++ b/src/libcamera/base/utils.cpp
> @@ -276,21 +276,6 @@ std::string details::StringSplitter::iterator::operator*() const
> return ss_->str_.substr(pos_, count);
> }
>
> -bool details::StringSplitter::iterator::operator!=(const details::StringSplitter::iterator &other) const
> -{
> - return pos_ != other.pos_;
> -}
> -
> -details::StringSplitter::iterator details::StringSplitter::begin() const
> -{
> - return iterator(this, 0);
> -}
> -
> -details::StringSplitter::iterator details::StringSplitter::end() const
> -{
> - return iterator(this, std::string::npos);
> -}
> -
> /**
> * \fn template<typename Container, typename UnaryOp> \
> * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list