You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi !
Is there any plan on adding support of Span<byte> / Memory<byte> where byte[] is currently required ?
(given that the introduction of these types help enhance memory usage and are spreading across the SDK)
Memory<byte>buffer= GetBuffer();Guidid= Guid.NewGuid();stringfileName= section.FileName;stringfullPath=$"upload/{id}";Streamstream= section.Section.Body;intbytesRead=0;// Streaming of the filedo{bytesRead=await stream.ReadAsync(buffer.Memory, ct);await _storage.WriteAsync(fullPath, buffer.Memory.ToArray(),true, cancellationToken: ct);}while(bytesRead>0);
which could be rewritten
Memory<byte>buffer= GetBuffer();Guidid= Guid.NewGuid();stringfileName= section.FileName;stringfullPath=$"upload/{id}";Streamstream= section.Section.Body;intbytesRead=0;// Streaming of the filedo{bytesRead=await stream.ReadAsync(buffer.Memory, ct);await _storage.WriteAsync(fullPath, buffer.Memory,true, cancellationToken: ct);}while(bytesRead>0);
From what i've seen in the codebase, it would require to either :
go through all existing IBlobStorage implementations to add support for this but with a default interface implementation, the change could be as minimal as adding default method
Hi !
Is there any plan on adding support of
Span<byte>
/Memory<byte>
wherebyte[]
is currently required ?(given that the introduction of these types help enhance memory usage and are spreading across the SDK)
Here a example where I think having overloads that accepts Span or Memory depending on the context could help
which could be rewritten
From what i've seen in the codebase, it would require to either :
IBlobStorage
implementations to add support for this but with a default interface implementation, the change could be as minimal as adding default methodThis has the advantage of allowing implementors to provide a more memory efficient approach without breaking them (
net6.0
upwards)IBlobStorage.WriteAsync
extension method that would take aMemory<byte>
instead ofbyte[]
Is that something that make sense to you ?
The text was updated successfully, but these errors were encountered: