Lucene.Net.Codecs: Removed unnecessary HashMapHelperClass
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/e106720c Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/e106720c Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/e106720c Branch: refs/heads/api-work Commit: e106720c52a0058e7ccf15b2ea98f8bdb71e9d1c Parents: 87a256e Author: Shad Storhaug <[email protected]> Authored: Sun Jan 29 16:54:27 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Sun Jan 29 17:10:26 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj | 1 - .../SimpleText/SimpleTextDocValuesReader.cs | 3 +- src/Lucene.Net.Codecs/StringHelperClass.cs | 123 ------------------- 3 files changed, 2 insertions(+), 125 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e106720c/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj b/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj index aff960b..19e2f64 100644 --- a/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj +++ b/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj @@ -117,7 +117,6 @@ <Compile Include="SimpleText\SimpleTextTermVectorsReader.cs" /> <Compile Include="SimpleText\SimpleTextTermVectorsWriter.cs" /> <Compile Include="SimpleText\SimpleTextUtil.cs" /> - <Compile Include="StringHelperClass.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Lucene.Net.Core\Lucene.Net.csproj"> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e106720c/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs index 027f436..8e03742 100644 --- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs +++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs @@ -42,6 +42,7 @@ namespace Lucene.Net.Codecs.SimpleText using BytesRef = Util.BytesRef; using StringHelper = Util.StringHelper; using System.Numerics; + using System.Text.RegularExpressions; public class SimpleTextDocValuesReader : DocValuesProducer // LUCENENET NOTE: Changed from internal to public because it is subclassed by a public class { @@ -494,7 +495,7 @@ namespace Lucene.Net.Codecs.SimpleText docID * (1 + _field.OrdPattern.Length)); SimpleTextUtil.ReadLine(_input, _scratch); var ordList = _scratch.Utf8ToString().Trim(); - _currentOrds = ordList.Length == 0 ? new string[0] : ordList.Split(",", true); + _currentOrds = ordList.Length == 0 ? new string[0] : ordList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); _currentIndex = 0; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e106720c/src/Lucene.Net.Codecs/StringHelperClass.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/StringHelperClass.cs b/src/Lucene.Net.Codecs/StringHelperClass.cs deleted file mode 100644 index 67505f3..0000000 --- a/src/Lucene.Net.Codecs/StringHelperClass.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -//------------------------------------------------------------------------------------------- -// Copyright © 2007 - 2014 Tangible Software Solutions Inc. -// This class can be used by anyone provided that the copyright notice remains intact. -// -// This class is used to convert some aspects of the Java String class. -//------------------------------------------------------------------------------------------- - -using System.Runtime.InteropServices; - -namespace Lucene.Net.Codecs -{ - - - // LUCENENET TODO: Remove this class - internal static class StringHelperClass - { - //---------------------------------------------------------------------------------- - // This method replaces the Java String.substring method when 'start' is a - // method call or calculated value to ensure that 'start' is obtained just once. - //---------------------------------------------------------------------------------- - internal static string SubstringSpecial(this string self, int start, int end) - { - return self.Substring(start, end - start); - } - - //------------------------------------------------------------------------------------ - // This method is used to replace calls to the 2-arg Java String.startsWith method. - //------------------------------------------------------------------------------------ - internal static bool StartsWith(this string self, string prefix, int toffset) - { - return self.IndexOf(prefix, toffset, System.StringComparison.Ordinal) == toffset; - } - - //------------------------------------------------------------------------------ - // This method is used to replace most calls to the Java String.split method. - //------------------------------------------------------------------------------ - internal static string[] Split(this string self, string regexDelimiter, bool trimTrailingEmptyStrings) - { - string[] splitArray = System.Text.RegularExpressions.Regex.Split(self, regexDelimiter); - - if (trimTrailingEmptyStrings) - { - if (splitArray.Length > 1) - { - for (int i = splitArray.Length; i > 0; i--) - { - if (splitArray[i - 1].Length > 0) - { - if (i < splitArray.Length) - System.Array.Resize(ref splitArray, i); - - break; - } - } - } - } - - return splitArray; - } - - #region These methods are used to replace calls to some Java String constructors. - - internal static string NewString(sbyte[] bytes) - { - return NewString(bytes, 0, bytes.Length); - } - - internal static string NewString(sbyte[] bytes, int index, int count) - { - return System.Text.Encoding.UTF8.GetString((byte[]) (object) bytes, index, count); - } - - internal static string NewString(sbyte[] bytes, string encoding) - { - return NewString(bytes, 0, bytes.Length, encoding); - } - - internal static string NewString(sbyte[] bytes, int index, int count, string encoding) - { - return System.Text.Encoding.GetEncoding(encoding).GetString((byte[]) (object) bytes, index, count); - } - - #endregion - - #region These methods are used to replace calls to the Java String.getBytes methods. - - internal static sbyte[] GetBytes(this string self) - { - return GetSBytesForEncoding(System.Text.Encoding.UTF8, self); - } - - internal static sbyte[] GetBytes(this string self, string encoding) - { - return GetSBytesForEncoding(System.Text.Encoding.GetEncoding(encoding), self); - } - - private static sbyte[] GetSBytesForEncoding(System.Text.Encoding encoding, string s) - { - var sbytes = new sbyte[encoding.GetByteCount(s)]; - encoding.GetBytes(s, 0, s.Length, (byte[]) (object) sbytes, 0); - return sbytes; - } - - #endregion - } -} \ No newline at end of file
