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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user