This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 2a0c97498 PERFORMANCE:
Lucene.Net.Replicator.LocalReplicator.ReplicationSession: Use
J2N.Collections.Dictionary<TKey, TValue> to allow deleting while iterating
forward prior to .NET Core (fixes #1070). (#1108)
2a0c97498 is described below
commit 2a0c97498e4bd77d98cedc990a4053fa0cde7d52
Author: Shad Storhaug <[email protected]>
AuthorDate: Mon Jan 20 22:33:44 2025 +0700
PERFORMANCE: Lucene.Net.Replicator.LocalReplicator.ReplicationSession: Use
J2N.Collections.Dictionary<TKey, TValue> to allow deleting while iterating
forward prior to .NET Core (fixes #1070). (#1108)
---
src/Lucene.Net.Replicator/LocalReplicator.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Lucene.Net.Replicator/LocalReplicator.cs
b/src/Lucene.Net.Replicator/LocalReplicator.cs
index 52f30e87a..f66540b03 100644
--- a/src/Lucene.Net.Replicator/LocalReplicator.cs
+++ b/src/Lucene.Net.Replicator/LocalReplicator.cs
@@ -6,6 +6,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
+using JCG = J2N.Collections.Generic;
namespace Lucene.Net.Replicator
{
@@ -132,14 +133,13 @@ public virtual void MarkAccessed()
private volatile bool disposed = false;
private readonly AtomicInt32 sessionToken = new AtomicInt32(0);
- private readonly IDictionary<string, ReplicationSession> sessions =
new Dictionary<string, ReplicationSession>();
+ private readonly JCG.Dictionary<string, ReplicationSession> sessions =
new JCG.Dictionary<string, ReplicationSession>();
/// <exception cref="InvalidOperationException"></exception>
private void CheckExpiredSessions()
{
- // .NET NOTE: .ToArray() so we don't modify a collection we are
enumerating...
- // I am wondering if it would be overall more practical
to switch to a concurrent dictionary...
- foreach (ReplicationSession token in sessions.Values.Where(token
=> token.IsExpired(ExpirationThreshold)).ToArray())
+ // LUCENENET NOTE: JCG.Dictionary<TKey, TValue> required for
deleting while iterating forward prior to .NET Core
+ foreach (ReplicationSession token in sessions.Values.Where(token
=> token.IsExpired(ExpirationThreshold)))
{
ReleaseSession(token.Session.Id);
}