Imported Upstream version 4.0.1

Former-commit-id: 757121caeaad523350be5330f0a3ecc891c70fb8
This commit is contained in:
Jo Shields
2015-04-26 19:10:23 +01:00
parent 7fce50ac98
commit c54b0bda4e
252 changed files with 16715 additions and 1176 deletions

View File

@@ -16,6 +16,7 @@ namespace System.Text {
using System.Text;
using System.Runtime;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
@@ -43,6 +44,7 @@ namespace System.Text {
//
[System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
[StructLayout (LayoutKind.Sequential)]
public sealed class StringBuilder : ISerializable {
// A StringBuilder is internally represented as a linked list of blocks each of which holds
// a chunk of the string. It turns out string as a whole can also be represented as just a chunk,

View File

@@ -29,6 +29,9 @@ namespace System.Text
// Unicode version 2.0 character size in bytes
public const int CharSize = 2;
// endianness-based bit pattern mask.
static readonly ulong highLowPatternMask = ((ulong) 0xd800d800d800d800 | (BitConverter.IsLittleEndian ? (ulong) 0x0400000004000000 : (ulong) 0x0000040000000400));
public UnicodeEncoding()
: this(false, true)
@@ -533,11 +536,7 @@ namespace System.Text
// If they happen to be high/low/high/low, we may as well continue. Check the next
// bit to see if its set (low) or not (high) in the right pattern
#if BIGENDIAN
if (((0xfc00fc00fc00fc00 & *longChars) ^ 0xd800dc00d800dc00) != 0)
#else
if (((0xfc00fc00fc00fc00 & *longChars) ^ 0xdc00d800dc00d800) != 0)
#endif
if (((0xfc00fc00fc00fc00 & *longChars) ^ highLowPatternMask) != 0)
{
// Either there weren't 4 surrogates, or the 0x0400 bit was set when a high
// was hoped for or the 0x0400 bit wasn't set where a low was hoped for.
@@ -823,11 +822,7 @@ namespace System.Text
// If they happen to be high/low/high/low, we may as well continue. Check the next
// bit to see if its set (low) or not (high) in the right pattern
#if BIGENDIAN
if (((0xfc00fc00fc00fc00 & *longChars) ^ 0xd800dc00d800dc00) != 0)
#else
if (((0xfc00fc00fc00fc00 & *longChars) ^ 0xdc00d800dc00d800) != 0)
#endif
if (((0xfc00fc00fc00fc00 & *longChars) ^ highLowPatternMask) != 0)
{
// Either there weren't 4 surrogates, or the 0x0400 bit was set when a high
// was hoped for or the 0x0400 bit wasn't set where a low was hoped for.
@@ -1228,11 +1223,7 @@ namespace System.Text
// If they happen to be high/low/high/low, we may as well continue. Check the next
// bit to see if its set (low) or not (high) in the right pattern
#if BIGENDIAN
if (((0xfc00fc00fc00fc00 & *longBytes) ^ 0xd800dc00d800dc00) != 0)
#else
if (((0xfc00fc00fc00fc00 & *longBytes) ^ 0xdc00d800dc00d800) != 0)
#endif
if (((0xfc00fc00fc00fc00 & *longBytes) ^ highLowPatternMask) != 0)
{
// Either there weren't 4 surrogates, or the 0x0400 bit was set when a high
// was hoped for or the 0x0400 bit wasn't set where a low was hoped for.
@@ -1560,11 +1551,7 @@ namespace System.Text
// If they happen to be high/low/high/low, we may as well continue. Check the next
// bit to see if its set (low) or not (high) in the right pattern
#if BIGENDIAN
if (((0xfc00fc00fc00fc00 & *longBytes) ^ 0xd800dc00d800dc00) != 0)
#else
if (((0xfc00fc00fc00fc00 & *longBytes) ^ 0xdc00d800dc00d800) != 0)
#endif
if (((0xfc00fc00fc00fc00 & *longBytes) ^ highLowPatternMask) != 0)
{
// Either there weren't 4 surrogates, or the 0x0400 bit was set when a high
// was hoped for or the 0x0400 bit wasn't set where a low was hoped for.