You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/05/09 11:53:35 UTC
[Lucene.Net] svn commit: r1100935 - in
/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core:
Index/FieldsReader.cs Support/FileSupport.cs
Author: digy
Date: Mon May 9 09:53:35 2011
New Revision: 1100935
URL: http://svn.apache.org/viewvc?rev=1100935&view=rev
Log:
[LUCENENET-412] "defaultEncoding" added to FieldsReader
Modified:
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/FieldsReader.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/FieldsReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/FieldsReader.cs?rev=1100935&r1=1100934&r2=1100935&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/FieldsReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/FieldsReader.cs Mon May 9 09:53:35 2011
@@ -61,6 +61,10 @@ namespace Lucene.Net.Index
private CloseableThreadLocal fieldsStreamTL = new CloseableThreadLocal();
private bool isOriginal = false;
+
+ //DIGY
+ //To avoid to call "System.Text.Encoding.GetEncoding("UTF-8")" repeatedly
+ private System.Text.Encoding defaultEncoding = System.Text.Encoding.GetEncoding("UTF-8");
/// <summary>Returns a cloned FieldsReader that shares open
/// IndexInputs with the original one. It is the caller's
@@ -434,7 +438,7 @@ namespace Lucene.Net.Index
byte[] b = new byte[toRead];
fieldsStream.ReadBytes(b, 0, b.Length);
- f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index, termVector);
+ f = new Field(fi.name, false, defaultEncoding.GetString(Uncompress(b)), store, index, termVector);
f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
f.SetOmitNorms(fi.omitNorms);
}
@@ -612,7 +616,7 @@ namespace Lucene.Net.Index
{
byte[] b = new byte[toRead];
localFieldsStream.ReadBytes(b, 0, b.Length);
- fieldsData = System.Text.Encoding.GetEncoding("UTF-8").GetString(Enclosing_Instance.Uncompress(b));
+ fieldsData = Enclosing_Instance.defaultEncoding.GetString(Enclosing_Instance.Uncompress(b));
}
else
{
@@ -620,7 +624,7 @@ namespace Lucene.Net.Index
{
byte[] bytes = new byte[toRead];
localFieldsStream.ReadBytes(bytes, 0, toRead);
- fieldsData = System.Text.Encoding.GetEncoding("UTF-8").GetString(bytes);
+ fieldsData = Enclosing_Instance.defaultEncoding.GetString(bytes);
}
else
{
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs?rev=1100935&r1=1100934&r2=1100935&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs Mon May 9 09:53:35 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
namespace Lucene.Net.Support
{
@@ -53,7 +54,7 @@ namespace Lucene.Net.Support
Lucene.Net.Index.IndexFileNameFilter indexFileNameFilter)
{
System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(fullName);
- System.Collections.ArrayList list = new System.Collections.ArrayList();
+ List<string> list = new List<string>();
foreach (System.IO.FileInfo fInfo in dInfo.GetFiles())
{
if (indexFileNameFilter.Accept(fInfo, fInfo.Name) == true)
@@ -61,9 +62,7 @@ namespace Lucene.Net.Support
list.Add(fInfo.Name);
}
}
- System.String[] retFiles = new System.String[list.Count];
- list.CopyTo(retFiles);
- return retFiles;
+ return list.ToArray();
}
// Disable the obsolete warning since we must use FileStream.Handle