Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -88,14 +88,46 @@ namespace System.Globalization
return internal_index_switch (source, startIndex, count, target, options, true);
}
unsafe int IndexOfCore (ReadOnlySpan<char> source, ReadOnlySpan<char> target, CompareOptions options, int* matchLengthPtr)
{
// TODO: optimize
var s = new string (source);
var t = new string (target);
return IndexOfCore (s, t, 0, s.Length, options, matchLengthPtr);
}
int IndexOfOrdinalCore (ReadOnlySpan<char> source, ReadOnlySpan<char> value, bool ignoreCase)
{
// TODO: optimize
var s = new string (source);
var v = new string (value);
if (!ignoreCase)
return s.IndexOfUnchecked (v, 0, s.Length);
return s.IndexOfUncheckedIgnoreCase (v, 0, s.Length);
}
int CompareString (ReadOnlySpan<char> string1, string string2, CompareOptions options)
{
throw new NotImplementedException ();
// TODO: optimize
var s1 = new string (string1);
return internal_compare_switch (s1, 0, s1.Length, string2, 0, string2.Length, options);
}
int CompareString (ReadOnlySpan<char> string1, ReadOnlySpan<char> string2, CompareOptions options)
{
throw new NotImplementedException ();
// TODO: optimize
var s1 = new string (string1);
var s2 = new string (string2);
return internal_compare_switch (s1, 0, s1.Length, new string (s2), 0, s2.Length, options);
}
unsafe static bool IsSortable (char *text, int length)
@@ -125,6 +157,12 @@ namespace System.Globalization
return Compare (source, 0, prefix.Length, prefix, 0, prefix.Length, options) == 0;
}
bool StartsWith (ReadOnlySpan<char> source, ReadOnlySpan<char> prefix, CompareOptions options)
{
// TODO: optimize
return StartsWith (new string (source), new string (prefix), options);
}
bool EndsWith (string source, string suffix, CompareOptions options)
{
if (UseManagedCollation)
@@ -136,6 +174,12 @@ namespace System.Globalization
return Compare (source, source.Length - suffix.Length, suffix.Length, suffix, 0, suffix.Length, options) == 0;
}
bool EndsWith (ReadOnlySpan<char> source, ReadOnlySpan<char> suffix, CompareOptions options)
{
// TODO: optimize
return EndsWith (new string (source), new string (suffix), options);
}
internal int GetHashCodeOfStringCore (string source, CompareOptions options)
{
return GetSortKey (source, options).GetHashCode ();

View File

@@ -1,15 +0,0 @@
using System.Runtime.CompilerServices;
namespace System
{
partial class MemoryExtensions
{
public static ReadOnlySpan<char> AsSpan (this string text)
{
if (text == null)
return default;
return new ReadOnlySpan<char> (Unsafe.As<Pinnable<char>> (text), StringAdjustment, text.Length);
}
}
}

View File

@@ -0,0 +1,62 @@
//
// RuntimeImports.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2018 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.CompilerServices;
#if BIT64
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif
namespace System.Runtime
{
static class RuntimeImports
{
internal static unsafe void RhZeroMemory (ref byte b, nuint byteLength)
{
fixed (byte* bytePointer = &b) {
ZeroMemory (bytePointer, (uint)byteLength);
}
}
internal static unsafe void RhZeroMemory (IntPtr p, UIntPtr byteLength)
{
ZeroMemory ((void*)p, (uint) byteLength);
}
[MethodImpl (MethodImplOptions.InternalCall)]
static extern unsafe void ZeroMemory (void* p, uint byteLength);
[MethodImpl (MethodImplOptions.InternalCall)]
internal static extern unsafe void Memmove (byte* dest, byte* src, uint len);
[MethodImpl (MethodImplOptions.InternalCall)]
internal static extern unsafe void Memmove_wbarrier (byte* dest, byte* src, uint len, IntPtr type_handle);
}
}

View File

@@ -1 +1 @@
ec5b4344a30b08f8137db41ec67c1b34702c56b8
8ece558dd28f5a3fe538b92be0dd6563dea791da