Skip to content

Commit

Permalink
Fixed implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
quajak committed Oct 26, 2019
1 parent ecfb7fe commit 9295b39
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions source/Cosmos.Core_Plugs/System/StringImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,15 @@ public static int IndexOf(string aThis, string aSubstring, int aIdx, int aLength
{
return aIdx;
}
return boyerMooreHorsepool(aSubstring, aThis.Substring(aIdx, aLength));
int pos = boyerMooreHorsepool(aSubstring, aThis.Substring(aIdx, aLength));
if (pos == -1)
{
return pos;
}
else
{
return pos + aIdx; //To account for offset
}
}

public static bool Contains(string aThis, string value)
Expand Down Expand Up @@ -637,25 +645,29 @@ public static int LastIndexOf(string aThis, string aString, int aIndex, int aCou
{
if (aString == String.Empty)
{
if (aIndex > aThis.Length)
{
return aThis.Length;
}
return aIndex;
}

string curr = "";
char[] chars = aString.ToCharArray();
char[] chars = aThis.ToCharArray();
for (int i = 0; i < aCount; i++)
{
curr += chars[aThis.Length - i];
curr = chars[aThis.Length - i - 1] + curr;
if (curr.StartsWith(aString))
{
return aThis.Length - 1;
return aThis.Length - i - 1;
}
}
return -1;
}

public static int LastIndexOf(string aThis, char aChar, int aStartIndex, int aCount)
{
return LastIndexOfAny(aThis, new[] { aChar }, aStartIndex, aCount);
return LastIndexOf(aThis, new string(aChar, 1), aStartIndex, aCount);
}

public static int LastIndexOfAny(string aThis, char[] aChars, int aStartIndex, int aCount)
Expand Down Expand Up @@ -1005,7 +1017,7 @@ public static unsafe int CompareOrdinalHelper(string strA, int indexA, int count

/*
* This optimization is not taking effect yet in Cosmos as String.Intern() is not implemented
*/
*/
if (ReferenceEquals(strA, strB))
{
mDebugger.SendInternal($"strA ({strA}) is the same object of strB ({strB}) returning 0");
Expand Down

0 comments on commit 9295b39

Please sign in to comment.