[Xamarin.Android.Build.Tasks] ResolveLibraryProjectImports temp files #2540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When reviewing
ResolveLibraryProjectImports
, I noticed a few thingswe could improve:
GetResourceData
to get the entire contents of a fileas a
byte[]
and then writing to disk.then deleting them.
The first thing I did was take advantage of the
GetResourceStream
method, so we could just do
stream.CopyTo(file)
. This prevents usfrom allocating big
byte[]
the size of each file.Next, I took advantage of
ZipArchive.Open (stream)
andGetResourceStream
to avoid the need for creating temporary zipfiles. We can unzip directly from the
Stream
in memory.Results
When timing these changes, I used the Xamarin.Forms integration
project in this repo:
I would say the improvements here are around 50ms.