-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Memorydesign-discussionOngoing discussion about design without consensusOngoing discussion about design without consensus
Milestone
Description
Before they are out there and it becomes a breaking change (byval => byref)
ReadOnlyMemory is a readonly struct; currently a copy is made and that copy is then passed by reference; but there is an advantage to passing it in and no-disadvantage (as call-site doesn't need to be annotated with in) and since it is readonly and passed by ref anyway due to its size.
e.g. changing
static int CompareOrdinalIgnoreCase(ReadOnlySpan<char> strA, ReadOnlySpan<char> strB)to
static int CompareOrdinalIgnoreCase(in ReadOnlySpan<char> strA, in ReadOnlySpan<char> strB)Changes the call site from
G_M57521_IG05:
lea rcx, bword ptr [rsp+38H]
mov bword ptr [rcx], r9
mov dword ptr [rcx+8], edx
lea rcx, bword ptr [rsp+28H]
mov bword ptr [rcx], r8
mov dword ptr [rcx+8], edx
lea rcx, bword ptr [rsp+38H]
lea rdx, bword ptr [rsp+28H]
call CompareInfo:CompareOrdinalIgnoreCase(struct,struct):intto
G_M57521_IG05:
mov bword ptr [rsp+28H], r8
mov dword ptr [rsp+30H], eax
lea rcx, bword ptr [rsp+28H]
call CompareInfo:CompareOrdinalIgnoreCase(byref,byref):intMetadata
Metadata
Assignees
Labels
area-System.Memorydesign-discussionOngoing discussion about design without consensusOngoing discussion about design without consensus