Skip to content

Commit a5fbe92

Browse files
committed
.
1 parent 16f7fbd commit a5fbe92

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

CImg.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26625,10 +26625,12 @@ namespace cimg_library {
2662526625
if (pos!=siz) // Move existing data in dynamic array
2662626626
cimg_forC(img,c) std::memmove(img.data(0,pos + count*nb_elts1,0,c),img.data(0,pos,0,c),(siz - pos)*sizeof(T));
2662726627

26628-
if (!dim) { // Scalar or vector1() elements
26629-
for (unsigned int k = 0; k<nb_elts; ++k) img[pos + k] = (T)_mp_arg(7 + k);
26630-
if (count>1)
26631-
for (unsigned int k = 1; k<count; ++k) std::memcpy(&img[pos + k*nb_elts],&img[pos],nb_elts*sizeof(T));
26628+
if (dim1==1) { // Scalar or vector1() elements
26629+
if (nb_elts) {
26630+
for (unsigned int k = 0; k<nb_elts; ++k) img[pos + k] = (T)_mp_arg(7 + k);
26631+
if (count>1)
26632+
for (unsigned int k = 1; k<count; ++k) std::memcpy(&img[pos + k*nb_elts],&img[pos],nb_elts*sizeof(T));
26633+
} else std::memset(&img[pos],0,count*sizeof(T));
2663226634
if (is_push_heap) for (unsigned int k = 0; k<nb_elts; ++k) {
2663326635
int index = pos + k;
2663426636
while (index>0) { // Heapify-up
@@ -26640,15 +26642,16 @@ namespace cimg_library {
2664026642
}
2664126643
}
2664226644
} else { // vectorN() elements, with N>1
26643-
for (unsigned int k = 0; k<nb_elts; ++k) {
26644-
T *ptrd = img.data(0,pos + k);
26645-
const double *const ptrs = &_mp_arg(7 + k) + 1;
26646-
cimg_forC(img,c) { *ptrd = ptrs[c]; ptrd+=img._height; }
26647-
}
26648-
if (count>1)
26649-
cimg_forC(img,c) for (unsigned int k = 1; k<count; ++k)
26650-
std::memcpy(img.data(0,pos + k*nb_elts,0,c),img.data(0,pos,0,c),nb_elts*sizeof(T));
26651-
26645+
if (nb_elts) {
26646+
for (unsigned int k = 0; k<nb_elts; ++k) {
26647+
T *ptrd = img.data(0,pos + k);
26648+
const double *const ptrs = &_mp_arg(7 + k) + 1;
26649+
cimg_forC(img,c) { *ptrd = ptrs[c]; ptrd+=img._height; }
26650+
}
26651+
if (count>1)
26652+
cimg_forC(img,c) for (unsigned int k = 1; k<count; ++k)
26653+
std::memcpy(img.data(0,pos + k*nb_elts,0,c),img.data(0,pos,0,c),nb_elts*sizeof(T));
26654+
} else cimg_forC(img,c) std::memset(img.data(0,pos,0,c),0,count*sizeof(T));
2665226655
if (is_push_heap) for (unsigned int k = 0; k<nb_elts; ++k) {
2665326656
int index = pos + k;
2665426657
while (index>0) { // Heapify-up

0 commit comments

Comments
 (0)