From 267a21810b54840ce9f9ec3da07543b2fafd346a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9lio=20Brun?= <lb@leliobrun.net> Date: Thu, 1 Jun 2023 01:10:06 +0900 Subject: [PATCH] optimize away the conditional in arrow_step since OTAWA says it is slightly better --- include/arrow.h | 8 +++----- include/arrow_spec.h | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/arrow.h b/include/arrow.h index 20cbdc08..abb92b21 100644 --- a/include/arrow.h +++ b/include/arrow.h @@ -27,11 +27,9 @@ extern void _arrow_dealloc (struct _arrow_mem *); #define _arrow_reset(self) {(self)->_reg._first = 1;} inline _Bool _arrow_step(struct _arrow_mem *self) { - if (self->_reg._first) { - self->_reg._first = 0; - return 1; - } - return 0; + _Bool old = self->_reg._first; + self->_reg._first = 0; + return old; } #endif diff --git a/include/arrow_spec.h b/include/arrow_spec.h index 06b717c1..d07f8b5e 100644 --- a/include/arrow_spec.h +++ b/include/arrow_spec.h @@ -67,12 +67,10 @@ extern void _arrow_dealloc (struct _arrow_mem *); inline _Bool _arrow_step(struct _arrow_mem *self) /*@ ghost (struct _arrow_mem_ghost \ghost *mem) */ { - if (self->_reg._first) { - self->_reg._first = 0; - //@ ghost mem->_reg._first = 0; - return 1; - } - return 0; + _Bool old = self->_reg._first; + self->_reg._first = 0; + //@ ghost mem->_reg._first = 0; + return old; } /*@ ghost -- GitLab