Commit bebb5ea
committed
[Xamarin.Android.Build.Tasks] ResolveLibraryProjectImports temp files
When reviewing `ResolveLibraryProjectImports`, I noticed a few things
we could improve:
1. We are using `GetResourceData` to get the entire contents of a file
as a `byte[]` and then writing to disk.
2. We are writing temporary zip files to disk, reading them to extract,
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 us
from allocating big `byte[]` the size of each file.
Next, I took advantage of `ZipArchive.Open (stream)` and
`GetResourceStream` to avoid the need for creating temporary zip
files. We can unzip directly from the `Stream` in memory.
~~ Results ~~
When timing these changes, I used the Xamarin.Forms integration
project in this repo:
Before
1. 1793 ms ResolveLibraryProjectImports 1 calls
2. 1780 ms ResolveLibraryProjectImports 1 calls
3. 1770 ms ResolveLibraryProjectImports 1 calls
After
1. 1750 ms ResolveLibraryProjectImports 1 calls
2. 1740 ms ResolveLibraryProjectImports 1 calls
3. 1702 ms ResolveLibraryProjectImports 1 calls
I would say the improvements here are around 50ms.1 parent e828fb3 commit bebb5ea
File tree
1 file changed
+8
-25
lines changed- src/Xamarin.Android.Build.Tasks/Tasks
1 file changed
+8
-25
lines changedLines changed: 8 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | | - | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | 295 | | |
303 | | - | |
| 296 | + | |
| 297 | + | |
304 | 298 | | |
305 | 299 | | |
306 | 300 | | |
| |||
318 | 312 | | |
319 | 313 | | |
320 | 314 | | |
321 | | - | |
322 | | - | |
323 | 315 | | |
324 | 316 | | |
325 | 317 | | |
326 | 318 | | |
327 | 319 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | 320 | | |
337 | 321 | | |
338 | | - | |
| 322 | + | |
| 323 | + | |
339 | 324 | | |
340 | 325 | | |
341 | 326 | | |
| |||
374 | 359 | | |
375 | 360 | | |
376 | 361 | | |
377 | | - | |
378 | | - | |
379 | 362 | | |
380 | 363 | | |
381 | 364 | | |
| |||
0 commit comments