optimization: only copy actual data to frontend

This commit is contained in:
itsmattkc 2024-11-15 15:50:34 -08:00
parent 5f86ab1498
commit 410b002d99

View file

@ -327,7 +327,12 @@ int get_event(event_loop_t *loop, vanilla_event_t *event, int wait)
if (loop->active && loop->used_index < loop->new_index) {
// Output data to pointer
*event = loop->events[loop->used_index % VANILLA_MAX_EVENT_COUNT];
vanilla_event_t *pull_event = &loop->events[loop->used_index % VANILLA_MAX_EVENT_COUNT];
event->type = pull_event->type;
memcpy(event->data, pull_event->data, pull_event->size);
event->size = pull_event->size;
loop->used_index++;
ret = 1;
}