mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-29 01:56:27 +00:00
[client] egl: simplify filter moving logic with memmove
This avoids duplicating the entire array of filters.
This commit is contained in:
parent
e040b88bf0
commit
ceff9dca9b
@ -120,23 +120,12 @@ static void configUI(void * opaque, int * id)
|
|||||||
|
|
||||||
if (doMove)
|
if (doMove)
|
||||||
{
|
{
|
||||||
EGL_Filter * tmp[count];
|
EGL_Filter * tmp = filters[moveIdx];
|
||||||
memcpy(tmp, filters, sizeof(*tmp) * count);
|
if (mouseIdx > moveIdx) // moving down
|
||||||
|
memmove(filters + moveIdx, filters + moveIdx + 1, (mouseIdx - moveIdx) * sizeof(EGL_Filter *));
|
||||||
size_t s = 0, d = 0;
|
else // moving up
|
||||||
for(size_t i = 0; i < count; ++i)
|
memmove(filters + mouseIdx + 1, filters + mouseIdx, (moveIdx - mouseIdx) * sizeof(EGL_Filter *));
|
||||||
{
|
filters[mouseIdx] = tmp;
|
||||||
if (i == mouseIdx)
|
|
||||||
{
|
|
||||||
filters[d++] = tmp[moveIdx];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s == moveIdx)
|
|
||||||
++s;
|
|
||||||
|
|
||||||
filters[d++] = tmp[s++];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw)
|
if (redraw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user