mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-03 10:40:39 +08:00
bug #1170: skip calls to memcpy/memmove for empty imput.
This commit is contained in:
parent
8d4d85161e
commit
b71ee76d8d
@ -507,7 +507,12 @@ template<typename T> void smart_copy(const T* start, const T* end, T* target)
|
|||||||
|
|
||||||
template<typename T> struct smart_copy_helper<T,true> {
|
template<typename T> struct smart_copy_helper<T,true> {
|
||||||
static inline void run(const T* start, const T* end, T* target)
|
static inline void run(const T* start, const T* end, T* target)
|
||||||
{ memcpy(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
|
{
|
||||||
|
std::ptrdiff_t size = std::ptrdiff_t(end)-std::ptrdiff_t(start);
|
||||||
|
if(size==0) return;
|
||||||
|
eigen_internal_assert(start!=0 && end!=0 && target!=0);
|
||||||
|
memcpy(target, start, size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct smart_copy_helper<T,false> {
|
template<typename T> struct smart_copy_helper<T,false> {
|
||||||
@ -515,7 +520,6 @@ template<typename T> struct smart_copy_helper<T,false> {
|
|||||||
{ std::copy(start, end, target); }
|
{ std::copy(start, end, target); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*** Implementation of runtime stack allocation (falling back to malloc) ***
|
*** Implementation of runtime stack allocation (falling back to malloc) ***
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user