From bdffdd7b9d8d5e0583b9490d6066c68dbf125274 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 30 Dec 2022 18:00:37 -0330 Subject: [PATCH] Minor string optimizations. --- src/common/bspf.hxx | 3 ++- src/emucore/FBSurface.hxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index a5f37de17..9a7f217b0 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -427,7 +427,8 @@ namespace BSPF inline bool isWhiteSpace(const char c) { - return string(" ,.;:+-*&/\\'").find(c) != string::npos; + static constexpr string_view spaces{" ,.;:+-*&/\\'"}; + return spaces.find(c) != string_view::npos; } } // namespace BSPF diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index ef2390cf9..b46db8485 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -411,7 +411,8 @@ class FBSurface @return True if whitespace character */ static bool isWhiteSpace(const char c) { - return string(" ,.;:+-*/\\'([\n").find(c) != string::npos; + static constexpr string_view spaces{" ,.;:+-*/\\'([\n"}; + return spaces.find(c) != string_view::npos; } protected: