lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [5/6] lucenenet git commit: Use List.AsReadOnly() when possible
Date Sun, 11 Jan 2015 00:33:18 GMT
Use List.AsReadOnly() when possible


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/b46c67ca
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/b46c67ca
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/b46c67ca

Branch: refs/heads/master
Commit: b46c67ca7344016a384dc6a101b2a1530fb6503d
Parents: b4d51ea
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Sun Jan 11 02:32:22 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Sun Jan 11 02:32:22 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Index/SegmentInfos.cs                | 2 +-
 src/Lucene.Net.Core/Support/Compatibility/Collections.cs | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b46c67ca/src/Lucene.Net.Core/Index/SegmentInfos.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SegmentInfos.cs b/src/Lucene.Net.Core/Index/SegmentInfos.cs
index 9ce4466..87c25ac 100644
--- a/src/Lucene.Net.Core/Index/SegmentInfos.cs
+++ b/src/Lucene.Net.Core/Index/SegmentInfos.cs
@@ -1410,7 +1410,7 @@ namespace Lucene.Net.Index
         /// Returns all contained segments as an <b>unmodifiable</b> <seealso
cref="List"/> view. </summary>
         public IList<SegmentCommitInfo> AsList()
         {
-            return Collections.UnmodifiableList<SegmentCommitInfo>(segments.ToArray());
+            return Collections.UnmodifiableList<SegmentCommitInfo>(segments);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b46c67ca/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
index c0126ec..9f29bbe 100644
--- a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
+++ b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
@@ -21,6 +21,11 @@ namespace Lucene.Net
             return ImmutableList.Create<T>(items.ToArray());
         }
 
+        public static IList<T> UnmodifiableList<T>(List<T> items)
+        {
+            return items.AsReadOnly();
+        }
+
         public static ISet<T> UnmodifiableSet<T>(IEnumerable<T> items)
         {
             return ImmutableHashSet.Create<T>(items.ToArray());


Mime
View raw message