basic/source/comp/scanner.cxx | 17 +++----- include/vcl/vclptr.hxx | 88 ++++++------------------------------------ 2 files changed, 22 insertions(+), 83 deletions(-)
New commits: commit 538765c85f46a1e658b769fc1e04a1e2b3a5838d Author: Mike Kaganski <[email protected]> AuthorDate: Wed May 21 10:56:44 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Thu May 22 06:07:59 2025 +0200 Simplify vclptr.hxx a bit Change-Id: I3d92dd98eaaedba377a5877c06aedc2991b79e48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185594 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index ea2fffe41790..e0e8a95085c1 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -66,9 +66,7 @@ class VclPtr public: /** Constructor... */ - VclPtr() - : m_rInnerRef() - {} + VclPtr() = default; /** Constructor... */ @@ -91,11 +89,8 @@ public: @param rRef another reference */ template< class derived_type > - VclPtr( - const VclPtr< derived_type > & rRef, - typename std::enable_if< - std::is_base_of<reference_type, derived_type>::value, int>::type - = 0 ) + requires std::is_base_of_v<reference_type, derived_type> + VclPtr(const VclPtr<derived_type>& rRef) : m_rInnerRef( static_cast<reference_type*>(rRef) ) { } @@ -124,9 +119,9 @@ public: * * @tparam reference_type must be a subclass of vcl::Window */ - template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) + template<typename... Arg> [[nodiscard]] static VclPtr Create(Arg &&... arg) { - return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); + return VclPtr( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); } /** Probably most common used: handle->someBodyOp(). @@ -162,13 +157,10 @@ public: @param rRef another reference */ template<typename derived_type> - typename std::enable_if< - std::is_base_of<reference_type, derived_type>::value, - VclPtr &>::type - operator =(VclPtr<derived_type> const & rRef) + requires std::is_base_of_v<reference_type, derived_type> + VclPtr & operator =(VclPtr<derived_type> const& rRef) { - m_rInnerRef.set(rRef.get()); - return *this; + return operator=(rRef.get()); } VclPtr & operator =(reference_type * pBody) @@ -210,7 +202,7 @@ public: /** Needed to place VclPtr's into STL collection. */ - bool operator< (const VclPtr<reference_type> & handle) const + bool operator< (const VclPtr & handle) const { return (m_rInnerRef < handle.m_rInnerRef); } @@ -239,29 +231,6 @@ template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { return p1 == p2.get(); } -template<typename T1, typename T2> -inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { - return !(p1 == p2); -} - -template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) -{ - return !(p1 == p2); -} - -template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { - return !(p1 == p2); -} - -template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) -{ - return !(p1 == p2); -} - -template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { - return !(p1 == p2); -} - /** * A construction helper for a temporary VclPtr. Since VclPtr types * are created with a reference-count of one - to help fit into @@ -294,15 +263,7 @@ class ScopedVclPtr : public VclPtr<reference_type> public: /** Constructor... */ - ScopedVclPtr() - : VclPtr<reference_type>() - {} - - /** Constructor - */ - ScopedVclPtr (reference_type * pBody) - : VclPtr<reference_type>(pBody) - {} + using VclPtr<reference_type>::VclPtr; /** Copy constructor... */ @@ -324,30 +285,12 @@ public: /** Assignment that releases the last reference. */ - ScopedVclPtr<reference_type>& operator = (reference_type * pBody) + ScopedVclPtr& operator = (reference_type * pBody) { disposeAndReset(pBody); return *this; } - /** Up-casting conversion constructor: Copies interface reference. - - Does not work for up-casts to ambiguous bases. For the special case of - up-casting to Reference< XInterface >, see the corresponding conversion - operator. - - @param rRef another reference - */ - template< class derived_type > - ScopedVclPtr( - const VclPtr< derived_type > & rRef, - typename std::enable_if< - std::is_base_of<reference_type, derived_type>::value, int>::type - = 0 ) - : VclPtr<reference_type>( rRef ) - { - } - /** Up-casting assignment operator. Does not work for up-casts to ambiguous bases. @@ -355,13 +298,10 @@ public: @param rRef another VclPtr */ template<typename derived_type> - typename std::enable_if< - std::is_base_of<reference_type, derived_type>::value, - ScopedVclPtr &>::type - operator =(VclPtr<derived_type> const & rRef) + requires std::is_base_of_v<reference_type, derived_type> + ScopedVclPtr& operator =(VclPtr<derived_type> const& rRef) { - disposeAndReset(rRef.get()); - return *this; + return operator=(rRef.get()); } /** commit 759c57bca1751546c5e83bdfad03ad255805c7a1 Author: Mike Kaganski <[email protected]> AuthorDate: Wed May 21 10:52:14 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Thu May 22 06:07:49 2025 +0200 No need to use vector here Change-Id: I1345ed034e92f4576e62ada2e85f1fd78d457fa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185593 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 820951889ad7..a95ee3a994a4 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -29,7 +29,6 @@ #include <rtl/character.hxx> #include <o3tl/string_view.hxx> #include <utility> -#include <vector> SbiScanner::SbiScanner(OUString _aBuf, StarBASIC* p) : aBuf(std::move(_aBuf)) @@ -211,14 +210,14 @@ bool SbiScanner::readLine() } // Function to check if a string is a valid compiler directive -static bool isValidCompilerDirective(std::u16string_view directive) { - static const std::vector<std::u16string_view> validDirectives = { - u"if", u"elseif", u"else", u"end", u"const" - }; - - return std::any_of(validDirectives.begin(), validDirectives.end(), [&](const auto& valid) { - return o3tl::matchIgnoreAsciiCase(directive, valid); - }); +static bool isValidCompilerDirective(std::u16string_view directive) +{ + static constexpr std::string_view validDirectives[] + = { "if", "elseif", "else", "end", "const" }; + + return std::any_of(std::begin(validDirectives), std::end(validDirectives), + [&directive](const auto& valid) + { return o3tl::matchIgnoreAsciiCase(directive, valid); }); } bool SbiScanner::NextSym()
