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:
Shawn O. Pearce
2010-08-04 13:56:49 -07:00
parent 5e8dbd4f7e
commit 6cbee9cb64

View File

@@ -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;
}