Skip to content

Commit f84985c

Browse files
committed
Split ternary operation over 2 lines
Improves readability.
1 parent 9477d68 commit f84985c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

system/lib/libc/musl/src/thread/__timedwait.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ int __timedwait_cp(volatile int *addr, int val,
8787
break;
8888
}
8989
// Must wait in slices in case this thread is cancelled in between.
90-
r = -emscripten_futex_wait((void*)addr, val,
91-
msecsToSleep > max_ms_slice_to_sleep ? max_ms_slice_to_sleep : msecsToSleep);
90+
if (msecsToSleep > max_ms_slice_to_sleep)
91+
msecsToSleep = max_ms_slice_to_sleep;
92+
r = -emscripten_futex_wait((void*)addr, val, msecsToSleep);
9293
} while (r == ETIMEDOUT);
9394
} else {
9495
// Can wait in one go.

system/lib/pthread/library_pthread.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ void emscripten_thread_sleep(double msecs) {
105105
ms_to_sleep = target - emscripten_get_now();
106106
if (ms_to_sleep < min_ms_slice_to_sleep)
107107
continue;
108-
109-
emscripten_futex_wait(&dummyZeroAddress, 0,
110-
ms_to_sleep > max_ms_slice_to_sleep ? max_ms_slice_to_sleep : ms_to_sleep);
108+
if (ms_to_sleep > max_ms_slice_to_sleep)
109+
ms_to_sleep = max_ms_slice_to_sleep;
110+
emscripten_futex_wait(&dummyZeroAddress, 0, ms_to_sleep);
111111
} while (ms_to_sleep > 0);
112112

113113
emscripten_conditional_set_current_thread_status(

0 commit comments

Comments
 (0)