diff options
author | Alex Perovich <alperovi@microsoft.com> | 2017-03-24 21:40:21 +0300 |
---|---|---|
committer | Alex Perovich <alperovi@microsoft.com> | 2017-03-24 21:40:21 +0300 |
commit | 7611aeec7edb077c2cdd538c3859fc24069b84fd (patch) | |
tree | 95c50e18f4f202a3ea2f05de475f04d5aa42f35d | |
parent | dd7bc60e519ea0bb6951f25d8d171a326f51277c (diff) |
Use Array.Copy with index and remove coreclr specific function
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index f6dd1abde..df1a88982 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -322,7 +322,7 @@ namespace System.Text { int newLen = value - m_ChunkOffset; char[] newArray = new char[newLen]; - Array.Copy(m_ChunkChars, newArray, m_ChunkLength); + Array.Copy(m_ChunkChars, 0, newArray, 0, m_ChunkLength); m_ChunkChars = newArray; } } @@ -532,7 +532,7 @@ namespace System.Text char[] newArray = new char[newLen]; Debug.Assert(newLen > chunk.m_ChunkChars.Length, "the new chunk should be larger than the one it is replacing"); - Array.Copy(chunk.m_ChunkChars, newArray, chunk.m_ChunkLength); + Array.Copy(chunk.m_ChunkChars, 0, newArray, 0, chunk.m_ChunkLength); m_ChunkChars = newArray; m_ChunkPrevious = chunk.m_ChunkPrevious; @@ -2141,37 +2141,6 @@ namespace System.Text } } - // Copies the source StringBuilder to the destination IntPtr memory allocated with len bytes. - internal unsafe void InternalCopy(IntPtr dest, int len) - { - if (len == 0) - return; - - bool isLastChunk = true; - byte* dstPtr = (byte*)dest.ToPointer(); - StringBuilder currentSrc = FindChunkForByte(len); - - do - { - int chunkOffsetInBytes = currentSrc.m_ChunkOffset * sizeof(char); - int chunkLengthInBytes = currentSrc.m_ChunkLength * sizeof(char); - fixed (char* charPtr = ¤tSrc.m_ChunkChars[0]) - { - byte* srcPtr = (byte*)charPtr; - if (isLastChunk) - { - isLastChunk = false; - Buffer.Memcpy(dstPtr + chunkOffsetInBytes, srcPtr, len - chunkOffsetInBytes); - } - else - { - Buffer.Memcpy(dstPtr + chunkOffsetInBytes, srcPtr, chunkLengthInBytes); - } - } - currentSrc = currentSrc.m_ChunkPrevious; - } while (currentSrc != null); - } - /// <summary> /// Finds the chunk for the logical index (number of characters in the whole stringbuilder) 'index' /// YOu can then get the offset in this chunk by subtracting the m_BlockOffset field from 'index' |