RefPatternMatcher#getUsernames: Remove premature optimization

Having more complicated code here to handle the case of empty emails
specially is not worth it.

Change-Id: Iddd04aa3e21d1f1dd603fc5ae65a77270288c578
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-23 13:41:15 +01:00
parent eb23e4f2be
commit 7b25bac23b

View File

@@ -134,13 +134,9 @@ public abstract class RefPatternMatcher {
private ImmutableSet<String> getUsernames(CurrentUser user) {
if (user.isIdentifiedUser()) {
ImmutableSet<String> emails = user.asIdentifiedUser().getEmailAddresses();
if (user.getUserName() == null) {
return emails;
} else if (emails.isEmpty()) {
return ImmutableSet.of(user.getUserName());
}
return Streams.concat(emails.stream(), ImmutableSet.of(user.getUserName()).stream())
return Streams.concat(
user.asIdentifiedUser().getEmailAddresses().stream(),
ImmutableSet.of(user.getUserName()).stream())
.collect(toImmutableSet());
}
if (user.getUserName() != null) {