diff options
author | David Robillard <d@drobilla.net> | 2018-09-23 13:47:44 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-23 13:47:44 +0200 |
commit | 9337cb4993f4db09567dc6e274b0a78aed99f136 (patch) | |
tree | 9f59fe3b1c321217959a5cd6dc07ff92fc834c11 | |
parent | e7041238e4d5ee3bb7e10680e0d786e22c279b30 (diff) | |
download | lv2-9337cb4993f4db09567dc6e274b0a78aed99f136.tar.xz |
Shrink code slightly by removing some if-else structure
-rw-r--r-- | lv2/atom/forge.h | 16 | ||||
-rw-r--r-- | lv2/event/event-helpers.h | 3 | ||||
-rw-r--r-- | lv2/log/logger.h | 8 |
3 files changed, 9 insertions, 18 deletions
diff --git a/lv2/atom/forge.h b/lv2/atom/forge.h index befbb6e..a77170f 100644 --- a/lv2/atom/forge.h +++ b/lv2/atom/forge.h @@ -167,11 +167,7 @@ lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map) static inline LV2_Atom* lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref) { - if (forge->buf) { - return (LV2_Atom*)ref; - } else { - return forge->deref(forge->handle, ref); - } + return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref); } /** @@ -361,12 +357,10 @@ lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t size, uint32_t type) static inline LV2_Atom_Forge_Ref lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a) { - if (lv2_atom_forge_top_is(forge, forge->Vector)) { - return lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size); - } else { - return lv2_atom_forge_write( - forge, a, (uint32_t)sizeof(LV2_Atom) + a->size); - } + return (lv2_atom_forge_top_is(forge, forge->Vector) + ? lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size) + : lv2_atom_forge_write( + forge, a, (uint32_t)sizeof(LV2_Atom) + a->size)); } /** Write an atom:Int. */ diff --git a/lv2/event/event-helpers.h b/lv2/event/event-helpers.h index eaac287..f514155 100644 --- a/lv2/event/event-helpers.h +++ b/lv2/event/event-helpers.h @@ -80,9 +80,8 @@ lv2_event_buffer_new(uint32_t capacity, uint16_t stamp_type) buf->capacity = capacity; lv2_event_buffer_reset(buf, stamp_type, (uint8_t *)(buf + 1)); return buf; - } else { - return NULL; } + return NULL; } diff --git a/lv2/log/logger.h b/lv2/log/logger.h index 0c608a6..7d9b005 100644 --- a/lv2/log/logger.h +++ b/lv2/log/logger.h @@ -94,11 +94,9 @@ lv2_log_vprintf(LV2_Log_Logger* logger, const char* fmt, va_list args) { - if (logger && logger->log) { - return logger->log->vprintf(logger->log->handle, type, fmt, args); - } else { - return vfprintf(stderr, fmt, args); - } + return ((logger && logger->log) + ? logger->log->vprintf(logger->log->handle, type, fmt, args) + : vfprintf(stderr, fmt, args)); } /** Log an error via lv2_log_vprintf(). */ |