Skip to content

Commit

Permalink
simplify valuesOrEmpty (#938)
Browse files Browse the repository at this point in the history
there are 3 lookups in the map, and one should be sufficient
  • Loading branch information
flisky authored and kdavisk6 committed May 13, 2019
1 parent 01b9560 commit a269e95
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/feign/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
* Returns an unmodifiable collection which may be empty, but is never null.
*/
public static <T> Collection<T> valuesOrEmpty(Map<String, Collection<T>> map, String key) {
return map.containsKey(key) && map.get(key) != null ? map.get(key) : Collections.<T>emptyList();
Collection<T> values = map.get(key);
return values != null ? values : Collections.emptyList();
}

public static void ensureClosed(Closeable closeable) {
Expand Down

0 comments on commit a269e95

Please sign in to comment.