ChangeUtil: Minor optimization to findChanges for change numbers
Don't bother with a regex, just use Ints.tryParse. Maintain existing behavior of skipping this codepath for numbers like 01234. Change-Id: I95cfdcd6171470e123c4e7046744072ea31a1399
This commit is contained in:
@@ -19,6 +19,7 @@ import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -439,10 +440,13 @@ public class ChangeUtil {
|
||||
public List<ChangeControl> findChanges(String id, CurrentUser user)
|
||||
throws OrmException {
|
||||
// Try legacy id
|
||||
if (id.matches("^[1-9][0-9]*$")) {
|
||||
if (!id.isEmpty() && id.charAt(0) != '0') {
|
||||
Integer n = Ints.tryParse(id);
|
||||
try {
|
||||
return ImmutableList.of(
|
||||
changeControlFactory.controlFor(Change.Id.parse(id), user));
|
||||
if (n != null) {
|
||||
return ImmutableList.of(
|
||||
changeControlFactory.controlFor(new Change.Id(n), user));
|
||||
}
|
||||
} catch (NoSuchChangeException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user