Skip to content

Commit 9fa77aa

Browse files
committed
wait_ns micro-optimisation
Use `+ 1` to set the "Thumb" indicator on the `delay_loop` routine address, rather than `| 1`. That makes it something that can be done by the linker, rather than needing to be done at run-time. Saves one instruction and one cycle.
1 parent ac68f80 commit 9fa77aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

platform/mbed_wait_api_no_rtos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static const uint16_t delay_loop_code[] = {
142142
};
143143

144144
/* Take the address of the code, set LSB to indicate Thumb, and cast to void() function pointer */
145-
#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code | 1))
145+
#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code + 1))
146146

147147
void wait_ns(unsigned int ns)
148148
{

0 commit comments

Comments
 (0)