mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
sched/sem : Optimize code
Simplify sem_trywait() code structure by removing redundant logic and consolidating return paths. This optimization maintains functional correctness while improving code clarity and reducing cyclomatic complexity. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This commit is contained in:
@@ -77,11 +77,6 @@ int nxsem_trywait_slow(FAR sem_t *sem)
|
||||
|
||||
/* If the semaphore is available, give it to the requesting task */
|
||||
|
||||
if (mutex)
|
||||
{
|
||||
new = nxsched_gettid();
|
||||
}
|
||||
|
||||
old = atomic_read(val);
|
||||
do
|
||||
{
|
||||
@@ -91,6 +86,8 @@ int nxsem_trywait_slow(FAR sem_t *sem)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
new = nxsched_gettid();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user