8283800: Simplify String.indexOf/lastIndexOf calls

Reviewed-by: xuelei, bpb, lmesnik
This commit is contained in:
Andrey Turbanov 2022-03-30 07:07:56 +00:00
parent b323f54fee
commit 9bb916db0a
6 changed files with 14 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -264,7 +264,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
throw new IllegalArgumentException("UUID string too large");
}
int dash1 = name.indexOf('-', 0);
int dash1 = name.indexOf('-');
int dash2 = name.indexOf('-', dash1 + 1);
int dash3 = name.indexOf('-', dash2 + 1);
int dash4 = name.indexOf('-', dash3 + 1);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,7 +63,7 @@ public class PropertyExpander {
if (value == null)
return null;
int p = value.indexOf("${", 0);
int p = value.indexOf("${");
// no special characters
if (p == -1) return value;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,7 +63,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
private static final long serialVersionUID = 7205873507486557157L;
/**
* The object identitifer being used for this algorithm.
* The object identifier being used for this algorithm.
*/
private ObjectIdentifier algid;
@ -584,7 +584,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
String upperCaseAlias = alias.toUpperCase(Locale.ENGLISH);
int index;
if (upperCaseAlias.startsWith("ALG.ALIAS") &&
(index = upperCaseAlias.indexOf("OID.", 0)) != -1) {
(index = upperCaseAlias.indexOf("OID.")) != -1) {
index += "OID.".length();
if (index == alias.length()) {
// invalid alias entry

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -100,7 +100,7 @@ public class DNSName implements GeneralNameInterface {
if (alphaDigits.indexOf(name.charAt(startIndex)) < 0) {
// Checking to make sure the wildcard only appears in the first component,
// and it has to be at least 3-char long with the form of *.[alphaDigit]
if ((name.length() < 3) || (name.indexOf('*', 0) != 0) ||
if ((name.length() < 3) || (name.indexOf('*') != 0) ||
(name.charAt(startIndex+1) != '.') ||
(alphaDigits.indexOf(name.charAt(startIndex+2)) < 0))
throw new IOException("DNSName components must begin with a letter, digit, "