From b6bfe0d42ec198ff421259f916d3d4cc378856b7 Mon Sep 17 00:00:00 2001 From: Mathieu Westphal Date: Wed, 25 Dec 2024 16:38:36 +0100 Subject: [PATCH 1/2] utils: Update API for C++17 --- library/public/utils.h | 2 +- library/src/utils.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/public/utils.h b/library/public/utils.h index 925e03283d..ffa62db4a4 100644 --- a/library/public/utils.h +++ b/library/public/utils.h @@ -26,7 +26,7 @@ class F3D_EXPORT utils * Compute the Levenshtein distance between two strings. * Can be useful for spell checking and typo detection. */ - [[nodiscard]] static unsigned int textDistance(const std::string& strA, const std::string& strB); + [[nodiscard]] static unsigned int textDistance(std::string_view strA, std::string_view strB); // clang-format off /** diff --git a/library/src/utils.cxx b/library/src/utils.cxx index 72222e6766..133cc36610 100644 --- a/library/src/utils.cxx +++ b/library/src/utils.cxx @@ -5,7 +5,7 @@ namespace f3d { //---------------------------------------------------------------------------- -unsigned int utils::textDistance(const std::string& strA, const std::string& strB) +unsigned int utils::textDistance(std::string_view strA, std::string_view strB) { return static_cast(detail::levenshtein(strA, strB)); } From a4020421da2a06e70a4b51f1ef03db3379920f9e Mon Sep 17 00:00:00 2001 From: Mathieu Westphal Date: Wed, 25 Dec 2024 16:39:44 +0100 Subject: [PATCH 2/2] window: Update API for C++17 (cherry picked from commit 7cec75bf8157620febfde1054463a7b84be518e4) --- library/private/window_impl.h | 2 +- library/public/window.h | 2 +- library/src/window_impl.cxx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/private/window_impl.h b/library/private/window_impl.h index addea7e956..283ce6af27 100644 --- a/library/private/window_impl.h +++ b/library/private/window_impl.h @@ -55,7 +55,7 @@ class window_impl : public window window& setSize(int width, int height) override; window& setPosition(int x, int y) override; window& setIcon(const unsigned char* icon, size_t iconSize) override; - window& setWindowName(const std::string& windowName) override; + window& setWindowName(std::string_view windowName) override; point3_t getWorldFromDisplay(const point3_t& displayPoint) const override; point3_t getDisplayFromWorld(const point3_t& worldPoint) const override; ///@} diff --git a/library/public/window.h b/library/public/window.h index 33d7aa9c6a..64bfabc70c 100644 --- a/library/public/window.h +++ b/library/public/window.h @@ -106,7 +106,7 @@ class F3D_EXPORT window /** * Set the window name to be shown by a window manager. */ - virtual window& setWindowName(const std::string& windowName) = 0; + virtual window& setWindowName(std::string_view windowName) = 0; /** * Convert a point in display coordinate to world coordinate. diff --git a/library/src/window_impl.cxx b/library/src/window_impl.cxx index 53107918a0..7e2f8e959c 100644 --- a/library/src/window_impl.cxx +++ b/library/src/window_impl.cxx @@ -315,9 +315,9 @@ window& window_impl::setIcon(const unsigned char* icon, size_t iconSize) } //---------------------------------------------------------------------------- -window& window_impl::setWindowName(const std::string& windowName) +window& window_impl::setWindowName(std::string_view windowName) { - this->Internals->RenWin->SetWindowName(windowName.c_str()); + this->Internals->RenWin->SetWindowName(windowName.data()); return *this; }