Optimize for single TransactionSynchronization
Optimize TransactionSynchronizationManager.getSynchronizations() to avoid sorting and ArrayList creation in case of a single TransactionSynchronization. See gh-27335
This commit is contained in:
parent
e737e6d9ba
commit
fd18c00e50
|
@ -297,6 +297,9 @@ public abstract class TransactionSynchronizationManager {
|
||||||
if (synchs.isEmpty()) {
|
if (synchs.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
else if (synchs.size() == 1) {
|
||||||
|
return Collections.singletonList(synchs.iterator().next());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Sort lazily here, not in registerSynchronization.
|
// Sort lazily here, not in registerSynchronization.
|
||||||
List<TransactionSynchronization> sortedSynchs = new ArrayList<>(synchs);
|
List<TransactionSynchronization> sortedSynchs = new ArrayList<>(synchs);
|
||||||
|
|
Loading…
Reference in New Issue