mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Optimize Ref<SparseMatrix> by removing useless default initialisation of SparseMapBase and SparseMatrix
This commit is contained in:
parent
9a070638de
commit
945b80c83e
@ -120,6 +120,9 @@ class SparseMapBase<Derived,ReadOnlyAccessors>
|
|||||||
|
|
||||||
/** Empty destructor */
|
/** Empty destructor */
|
||||||
inline ~SparseMapBase() {}
|
inline ~SparseMapBase() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline SparseMapBase() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
@ -172,6 +175,9 @@ class SparseMapBase<Derived,WriteAccessors>
|
|||||||
|
|
||||||
/** Empty destructor */
|
/** Empty destructor */
|
||||||
inline ~SparseMapBase() {}
|
inline ~SparseMapBase() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline SparseMapBase() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>
|
template<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>
|
||||||
|
@ -182,8 +182,9 @@ class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
|||||||
{
|
{
|
||||||
if((Options & int(StandardCompressedFormat)) && (!expr.isCompressed()))
|
if((Options & int(StandardCompressedFormat)) && (!expr.isCompressed()))
|
||||||
{
|
{
|
||||||
m_object = expr;
|
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||||
Base::construct(m_object);
|
::new (obj) TPlainObjectType(expr);
|
||||||
|
Base::construct(*obj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -194,12 +195,13 @@ class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
|||||||
template<typename Expression>
|
template<typename Expression>
|
||||||
void construct(const Expression& expr, internal::false_type)
|
void construct(const Expression& expr, internal::false_type)
|
||||||
{
|
{
|
||||||
m_object = expr;
|
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||||
Base::construct(m_object);
|
::new (obj) TPlainObjectType(expr);
|
||||||
|
Base::construct(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TPlainObjectType m_object;
|
char m_object_bytes[sizeof(TPlainObjectType)];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user