Use char instead of String in lastIndexOf calls
This is a bit more efficient and not harder to read. Change-Id: Ic3d93ab95734cfab14fa1e348022e616ef6e3eef
This commit is contained in:
@@ -344,7 +344,7 @@ class OpenIdServiceImpl {
|
||||
// of these domains.
|
||||
//
|
||||
final String email = areq.getEmailAddress();
|
||||
int emailAtIndex = email.lastIndexOf("@");
|
||||
int emailAtIndex = email.lastIndexOf('@');
|
||||
if (emailAtIndex >= 0 && emailAtIndex < email.length() - 1) {
|
||||
final String emailDomain = email.substring(emailAtIndex);
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
|
||||
private String extractWhat(Audit note, GerritCall call) {
|
||||
Class<?> methodClass = call.getMethodClass();
|
||||
String methodClassName = methodClass != null ? methodClass.getName() : "<UNKNOWN_CLASS>";
|
||||
methodClassName = methodClassName.substring(methodClassName.lastIndexOf(".") + 1);
|
||||
methodClassName = methodClassName.substring(methodClassName.lastIndexOf('.') + 1);
|
||||
String what = note.action();
|
||||
if (what.length() == 0) {
|
||||
what = call.getMethod().getName();
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ChangeEditUtil {
|
||||
|
||||
private PatchSet getBasePatchSet(ChangeNotes notes, Ref ref) throws IOException {
|
||||
try {
|
||||
int pos = ref.getName().lastIndexOf("/");
|
||||
int pos = ref.getName().lastIndexOf('/');
|
||||
checkArgument(pos > 0, "invalid edit ref: %s", ref.getName());
|
||||
String psId = ref.getName().substring(pos + 1);
|
||||
return psUtil.get(
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class NotificationEmail extends OutgoingEmail {
|
||||
|
||||
@VisibleForTesting
|
||||
protected static String getShortProjectName(String projectName) {
|
||||
int lastIndexSlash = projectName.lastIndexOf("/");
|
||||
int lastIndexSlash = projectName.lastIndexOf('/');
|
||||
if (lastIndexSlash == 0) {
|
||||
return projectName.substring(1); // Remove the first slash
|
||||
}
|
||||
@@ -144,6 +144,6 @@ public abstract class NotificationEmail extends OutgoingEmail {
|
||||
}
|
||||
// Extract the project name (everything after the last slash) and prepends it with gerrit's
|
||||
// instance name
|
||||
return instanceName + "/" + projectName.substring(projectName.lastIndexOf("/") + 1);
|
||||
return instanceName + "/" + projectName.substring(projectName.lastIndexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user