Search username cache before database by name
If the input string conforms to our username pattern, search the username cache as it will be quicker than looking at the database for a full name substring, and probably is going to match an account, especially in small group settings where people know each other's local usernames. Change-Id: I827f59d9c0fc9ce5b515b9611561d718733036d2 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -61,15 +61,18 @@ public class AccountResolver {
|
||||
return byId.get(Account.Id.parse(nameOrEmail)).getAccount();
|
||||
}
|
||||
|
||||
if (nameOrEmail.matches(Account.USER_NAME_PATTERN)) {
|
||||
Account who = findByUserName(nameOrEmail);
|
||||
if (who != null) {
|
||||
return who;
|
||||
}
|
||||
}
|
||||
|
||||
Account account = findByNameOrEmail(nameOrEmail);
|
||||
if (account != null) {
|
||||
return account;
|
||||
}
|
||||
|
||||
if (nameOrEmail.matches(Account.USER_NAME_PATTERN)) {
|
||||
return findByUserName(nameOrEmail);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user