mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8302590: Add String.indexOf(int ch, int fromIndex, int toIndex)
Reviewed-by: rriggs, alanb
This commit is contained in:
parent
cd4b88d0d2
commit
5b2e2e4695
4 changed files with 295 additions and 17 deletions
|
@ -192,18 +192,16 @@ final class StringLatin1 {
|
|||
};
|
||||
}
|
||||
|
||||
public static int indexOf(byte[] value, int ch, int fromIndex) {
|
||||
public static int indexOf(byte[] value, int ch, int fromIndex, int toIndex) {
|
||||
if (!canEncode(ch)) {
|
||||
return -1;
|
||||
}
|
||||
int max = value.length;
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = 0;
|
||||
} else if (fromIndex >= max) {
|
||||
// Note: fromIndex might be near -1>>>1.
|
||||
fromIndex = Math.max(fromIndex, 0);
|
||||
toIndex = Math.min(toIndex, value.length);
|
||||
if (fromIndex >= toIndex) {
|
||||
return -1;
|
||||
}
|
||||
return indexOfChar(value, ch, fromIndex, max);
|
||||
return indexOfChar(value, ch, fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@IntrinsicCandidate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue