Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Enhancement] Spanify possible platforms #1096

Closed
Mrnikbobjeff opened this issue Feb 11, 2020 · 3 comments
Closed

[Enhancement] Spanify possible platforms #1096

Mrnikbobjeff opened this issue Feb 11, 2020 · 3 comments
Labels
enhancement Small enhancement to the library feature-request A request for a new feature.

Comments

@Mrnikbobjeff
Copy link
Contributor

Mrnikbobjeff commented Feb 11, 2020

Summary

Android and iOS support the Span feature. In some instances we can really cut down on allocation with the Span feature. This would also become the default path once .NET 5 is released this year, as UWP will then finally support .NET Standard 2.1. Be aware that this could be at most one year off.

API Changes

A complete review would be required. This should also include looking at System.Buffers. I did that already, and there are no glaringly obvious ways to benefit from this feature sadly. Only one instance came up, and I am pretty sure it does not work as it occurs in _SecureStorage.Android, where the api could rely on exact buffer size. There would also need to be an audit where we can expose two different return types.

Intended Use Case

Reduce useless allocations, be future proof.

@Mrnikbobjeff Mrnikbobjeff added the feature-request A request for a new feature. label Feb 11, 2020
@jamesmontemagno jamesmontemagno added the enhancement Small enhancement to the library label Feb 11, 2020
@mattleibow
Copy link
Contributor

Do you see any areas where we could use Span<T>? I don't think we have any excessive use of arrays or other types of contiguous memory...

@Mrnikbobjeff
Copy link
Contributor Author

The thing which prompted this ticket was the WebUtils.shared.cs ParseQueryString where we do some string manipulation. Due to some substring operations I thought this was a good candidate. The savings here are not immense though as we have to materialize some spans in the end to populate our Dictionary<string,string>. This will probably also be our primary saving, string manipulation. As far as I am aware we only ever once create a byte array, so for that we really will not be getting any savings. Strings is where it is at for us

@jfversluis
Copy link
Member

I think at this point it's safe to say that this won't be making it's way into Xamarin.Essentials anymore. Keep your eye on .NET MAUI for all new development! Thanks for all input and efforts here.

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Small enhancement to the library feature-request A request for a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants