[FarGroup/FarManager] master: Refactoring (26fec4b95)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Dec 29, 2025, 1:00:54 PM12/29/25
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/26fec4b9554ea43ddd413a84d595f674435af7b3

>---------------------------------------------------------------

commit 26fec4b9554ea43ddd413a84d595f674435af7b3
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Mon Dec 29 17:43:26 2025 +0000

Refactoring


>---------------------------------------------------------------

26fec4b9554ea43ddd413a84d595f674435af7b3
far/common/smart_ptr.hpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/far/common/smart_ptr.hpp b/far/common/smart_ptr.hpp
index 578e9e905..01bc05074 100644
--- a/far/common/smart_ptr.hpp
+++ b/far/common/smart_ptr.hpp
@@ -50,9 +50,9 @@ class array_ptr
public:
NONCOPYABLE(array_ptr);

- array_ptr() noexcept
+ array_ptr() noexcept:
+ m_Buffer(std::in_place_type<static_type>)
{
- m_Buffer.template emplace<static_type>();
}

explicit array_ptr(size_t const Size, bool Init = false):
@@ -78,13 +78,15 @@ public:
{
if (Size > StaticSize)
{
- auto& DynamicBuffer = m_Buffer.template emplace<dynamic_type>();
+ auto& DynamicBuffer = std::holds_alternative<dynamic_type>(m_Buffer)?
+ std::get<dynamic_type>(m_Buffer) :
+ m_Buffer.template emplace<dynamic_type>();

// We don't need a strong guarantee here, so it's better to reduce memory usage
DynamicBuffer.reset();
DynamicBuffer.reset(Init? new T[Size]() : new T[Size]);
}
- else
+ else if (!std::holds_alternative<static_type>(m_Buffer))
{
m_Buffer.template emplace<static_type>();
}


Reply all
Reply to author
Forward
0 new messages