From 4203688c0fa7b5600252127cbbdecf43b1c6b94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Wed, 22 Dec 2021 09:37:42 -0800 Subject: [PATCH] Use `ImmutableMap.Builder.buildKeepingLast()` where appropriate. RELNOTES=n/a PiperOrigin-RevId: 417835702 --- .../java/com/google/common/jimfs/AttributeService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java index 333a49736..2b38ded45 100644 --- a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java +++ b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java @@ -316,7 +316,7 @@ public ImmutableMap readAttributes(File file, String attributes) throw new IllegalArgumentException("invalid attributes: " + attributes); } - Map result = new HashMap<>(); + ImmutableMap.Builder result = ImmutableMap.builder(); if (attrs.size() == 1 && attrs.contains(ALL_ATTRIBUTES)) { // for 'view:*' format, get all keys for all providers for the view AttributeProvider provider = providersByName.get(view); @@ -333,7 +333,7 @@ public ImmutableMap readAttributes(File file, String attributes) } } - return ImmutableMap.copyOf(result); + return result.buildKeepingLast(); } /** @@ -351,7 +351,8 @@ public A readAttributes(File file, Class type throw new UnsupportedOperationException("unsupported attributes type: " + type); } - private static void readAll(File file, AttributeProvider provider, Map map) { + private static void readAll( + File file, AttributeProvider provider, ImmutableMap.Builder map) { for (String attribute : provider.attributes(file)) { Object value = provider.get(file, attribute);