You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/01/28 10:10:28 UTC
[ignite] 06/09: Add localCandidatesMax to reduce allocations
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 96b3d9a01aefa9f58e2d9b255a85f1caa53e2559
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 12:39:43 2021 +0300
Add localCandidatesMax to reduce allocations
---
.../ignite/internal/processors/cache/GridCacheMvcc.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index ca4a66e..99cea01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -1448,12 +1448,20 @@ public final class GridCacheMvcc {
assert !col.isEmpty();
- List<GridCacheMvccCandidate> cands = new ArrayList<>(col.size());
+ List<GridCacheMvccCandidate> cands = null;
for (GridCacheMvccCandidate c : col) {
// Don't include reentries.
- if ((reentries || !c.reentry()) && c.version().isLess(maxVers))
+ if ((reentries || !c.reentry()) && c.version().isLess(maxVers)) {
+ if (cands == null)
+ cands = new ArrayList<>(col.size());
+
cands.add(c);
+ }
+ }
+
+ if (cands == null) {
+ cands = Collections.emptyList();
}
return cands;