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 {
writeLock.lock();
// 重新检查
if (i == currentIndex()) {
return false;
}
if ((!isLast() && i < currentIndex()) ||
(isLast() && i != getDefault())) {
final boolean isLast;
if (i == currentIndex() ||
(!(isLast = isLast()) && i < currentIndex()) ||
(isLast && i != getDefault())) {
return false;
}
updateCurrentIndex(i);