Make Encoding.Unicode.GetString faster on 64-bit platforms (#18263)
authorJan Kotas <jkotas@microsoft.com>
Mon, 4 Jun 2018 20:09:29 +0000 (13:09 -0700)
committerGitHub <noreply@github.com>
Mon, 4 Jun 2018 20:09:29 +0000 (13:09 -0700)
commit27cd821920a69ea6456284654e8d2b5c24de6b15
tree97cf1841890460b4593e334b6321b69c76753c67
parent613358db8c36ec5d564f2772de2d083c0f701754
Make Encoding.Unicode.GetString faster on 64-bit platforms (#18263)

UnicodeEncoding was taking fast path only when both source and destination were 8-byte aligned. It was not
the case for Unicode.GetString.

The fix is to just check the source alignment as fast path precondition, and use unaligned write for destination.

Also removed alternative fast path that is not needed anymore, tweaked local variable assignments for better
register allocation, and fixed performance issue introduced by recent big endian portability fix.
src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs