Skip to content

Commit

Permalink
[SofaKernel] Use new conditions to select copy-on-write
Browse files Browse the repository at this point in the history
Instead of relying on DataTypeInfo to detect if we should use copy-on-write
mechanisme use standard c++ type traits to do so.

NB: I'm not sure it make sense to handle a copy-on-write and non
copy-on-write. Because using Data is actually already a slow mechanisme...
so selecting between copy or non-copy mode is overkill. Forcing copy on write
to true has also zero noticeable performance cost on the caducesus.
So why not removig it.
  • Loading branch information
damienmarchal committed Aug 2, 2021
1 parent 384ca2d commit c72539a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ class Data : public BaseData
bool copyValueFrom(const BaseData* data){ return doCopyValueFrom(data); }
bool copyValueFrom(const Data<T>* data);

bool isCopyOnWrite(){ return sofa::defaulttype::DataTypeInfo<T>::CopyOnWrite; }
constexpr bool isCopyOnWrite(){ return std::is_scalar_v<T> || std::is_pointer_v<T>; }

protected:
typedef DataContentValue<T, sofa::defaulttype::DataTypeInfo<T>::CopyOnWrite> ValueType;
typedef DataContentValue<T, std::is_scalar_v<T> || std::is_pointer_v<T>> ValueType;

/// Value
ValueType m_value;
Expand Down

0 comments on commit c72539a

Please sign in to comment.