FData optimization

This commit is contained in:
Markus Gans 2020-09-18 22:40:51 +02:00
parent 5092244b81
commit ff2e29b246
4 changed files with 54 additions and 75 deletions

View File

@ -51,7 +51,7 @@ void doubleToItem ( FListBoxItem& item
, std::size_t index )
{
typedef std::list<double> DblList;
DblList& dbl_list = FListBoxHelper::getContainer<DblList>(container);
DblList& dbl_list = flistboxhelper::getContainer<DblList>(container);
std::list<double>::iterator iter = dbl_list.begin();
std::advance (iter, index);
item.setText (FString() << *iter);

View File

@ -834,7 +834,7 @@ void FListBox::drawList()
const bool lineHasBrackets = hasBrackets(iter);
// Import data via lazy conversion
lazyConvert (iter, int(y));
lazyConvert (iter, y);
// Set screen position and attributes
setLineAttributes ( int(y), isSelected(iter), lineHasBrackets

View File

@ -51,13 +51,11 @@ namespace finalcut
//----------------------------------------------------------------------
template <typename T>
struct FData; // Class forward declaration
class FData; // Class forward declaration
struct FDataAccess
class FDataAccess
{
public:
virtual ~FDataAccess();
template <typename T>
const T& get() const
{
@ -72,42 +70,24 @@ struct FDataAccess
}
};
//----------------------------------------------------------------------
inline FDataAccess::~FDataAccess()
{ }
//----------------------------------------------------------------------
// struct FData
//----------------------------------------------------------------------
template <typename T>
struct FData : public FDataAccess
class FData : public FDataAccess
{
public:
explicit FData (T& v) // constructor
: value_ref{v}
{ }
explicit FData (T&& v) // constructor
: value{v}
: value{std::move(v)}
, value_ref{value}
{ }
~FData() // destructor
{ }
FData (const FData& d) // Copy constructor
: value{d.value}
, value_ref{d.value_ref}
{ }
FData& operator = (const FData& d) // Copy assignment operator (=)
{
value = d.value;
value_ref = d.value_ref;
return *this;
}
T operator () () const
{
return value_ref;
@ -157,9 +137,8 @@ struct FData : public FDataAccess
}
private:
// Data members
T value{};
public:
T& value_ref;
};

View File

@ -371,7 +371,7 @@ class FListBox : public FWidget
// non-member function
//----------------------------------------------------------------------
namespace FListBoxHelper
namespace flistboxhelper
{
template <typename Container>