change: 精简逻辑代码.

This commit is contained in:
2025-01-07 09:24:52 +08:00
parent 1c87acef2a
commit 370a9eb75d

View File

@@ -68,12 +68,10 @@ public class DefaultUnidirectionalStateManager<S> extends AbstractStateManager<S
} }
try { try {
writeLock.lock(); writeLock.lock();
// 重新检查 final boolean isLast;
if (i == currentIndex()) { if (i == currentIndex() ||
return false; (!(isLast = isLast()) && i < currentIndex()) ||
} (isLast && i != getDefault())) {
if ((!isLast() && i < currentIndex()) ||
(isLast() && i != getDefault())) {
return false; return false;
} }
updateCurrentIndex(i); updateCurrentIndex(i);