Repository navigation
Conversation
|
Something this fundamental belongs in Extensions/Common, or at least down in WebUtils |
| fixed (char* value = _value) | ||
| fixed (char* pDomainToken = s) | ||
| { | ||
| Unsafe.CopyBlock(value + _offset, pDomainToken, (uint)s.Length * 2); |
There was a problem hiding this comment.
While this might currently work, don't think you can use CopyBlock as the spec says it expects all writes to be aligned dotnet/coreclr#7198 (comment)
ECMA-355 says:
"cpblk assumes that both destaddr and srcaddr are aligned to the natural size of the machine (but see the unaligned. prefix instruction). The operation of the cpblk instruction can be altered by an immediately preceding volatile. or unaligned. prefix instruction.
Might want to get a Unsafe.CopyBlockUnaligned added. This has also been pointed out in its use in corefxlabs
|
Raised issue for unaligned https://github.com/dotnet/corefx/issues/12243 |
|
Moved to dotnet/extensions#157 |
Intended to be used instead of pooled StringBuilder or string.Concat when all parts of string are known.
Does only 1 allocation of resulting string.
@benaadams @davidfowl @Tratcher @halter73 @rynowak