From e907474ea93278f9c95217f45738c5f94e0e249b Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 23 Feb 2023 19:07:43 +0100 Subject: [PATCH] Avoid double copy of mcv in emu_ev --- src/emu/emu_ev.c | 6 +++--- src/emu/emu_ev.h | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/emu/emu_ev.c b/src/emu/emu_ev.c index 05af80e..62acfec 100644 --- a/src/emu/emu_ev.c +++ b/src/emu/emu_ev.c @@ -7,9 +7,9 @@ void emu_ev(struct emu_ev *ev, const struct ovni_ev *oev, int64_t sclock, int64_t dclock) { - ev->mcv[0] = ev->m = oev->header.model; - ev->mcv[1] = ev->c = oev->header.category; - ev->mcv[2] = ev->v = oev->header.value; + ev->m = oev->header.model; + ev->c = oev->header.category; + ev->v = oev->header.value; ev->mcv[3] = '\0'; ev->rclock = oev->header.clock; diff --git a/src/emu/emu_ev.h b/src/emu/emu_ev.h index 10cdf17..3278d4c 100644 --- a/src/emu/emu_ev.h +++ b/src/emu/emu_ev.h @@ -9,10 +9,15 @@ /* Easier to parse emulation event */ struct emu_ev { - uint8_t m; - uint8_t c; - uint8_t v; - char mcv[4]; + union { + struct { + uint8_t m; + uint8_t c; + uint8_t v; + uint8_t nil; + }; + char mcv[4]; + }; int64_t rclock; /* As-is clock in the binary stream */ int64_t sclock; /* Corrected clock with stream offset */