WebLinks: Return List<T> from methods rather than FluentIterable<T>

All the callers of these methods convert the returned FluentIterable to
a List. Also it's inefficient to invoke FluentIterable.isEmpty() because
it has to traverse the whole thing including map and filter calls.

Change it to just return a List.

Rather than converting to use the Java 8 streams API, leave the internal
implementation of the methods unchanged for now. The links are DynamicSet,
which is an implementation of Iterable and does not have the stream()
method. There isn't much readability improvement by rewriting it to use
Spliterator, but we can revisit this later when we upgrade to Guava 21
which has a Streams utility.

Change-Id: I0e2a68f2992f6bcb2ab1ee2ae067975d416e9651
This commit is contained in:
David Pursehouse
2016-12-06 21:27:48 +09:00
parent 9b8be04d27
commit e32ef82ad7
8 changed files with 33 additions and 32 deletions

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.httpd.rpc.project;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Maps;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GroupDescription;
@@ -216,10 +215,10 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
}
private List<WebLinkInfoCommon> getConfigFileLogLinks(String projectName) {
FluentIterable<WebLinkInfoCommon> links =
List<WebLinkInfoCommon> links =
webLinks.getFileHistoryLinks(projectName, RefNames.REFS_CONFIG,
ProjectConfig.PROJECT_CONFIG);
return links.isEmpty() ? null : links.toList();
return links.isEmpty() ? null : links;
}
private Map<AccountGroup.UUID, GroupInfo> buildGroupInfo(List<AccessSection> local) {