mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8282664: Unroll by hand StringUTF16 and StringLatin1 polynomial hash loops
Co-authored-by: Sandhya Viswanathan <sviswanathan@openjdk.org> Co-authored-by: Ludovic Henry <luhenry@openjdk.org> Co-authored-by: Claes Redestad <redestad@openjdk.org> Reviewed-by: vlivanov, sviswanathan, luhenry
This commit is contained in:
parent
ade08e190c
commit
e37078f5bb
33 changed files with 1053 additions and 87 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, 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
|
||||
|
@ -189,11 +189,11 @@ final class StringLatin1 {
|
|||
}
|
||||
|
||||
public static int hashCode(byte[] value) {
|
||||
int h = 0;
|
||||
for (byte v : value) {
|
||||
h = 31 * h + (v & 0xff);
|
||||
}
|
||||
return h;
|
||||
return switch (value.length) {
|
||||
case 0 -> 0;
|
||||
case 1 -> value[0] & 0xff;
|
||||
default -> ArraysSupport.vectorizedHashCode(value, 0, value.length, 0, ArraysSupport.T_BOOLEAN);
|
||||
};
|
||||
}
|
||||
|
||||
public static int indexOf(byte[] value, int ch, int fromIndex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, 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
|
||||
|
@ -412,12 +412,11 @@ final class StringUTF16 {
|
|||
}
|
||||
|
||||
public static int hashCode(byte[] value) {
|
||||
int h = 0;
|
||||
int length = value.length >> 1;
|
||||
for (int i = 0; i < length; i++) {
|
||||
h = 31 * h + getChar(value, i);
|
||||
}
|
||||
return h;
|
||||
return switch (value.length) {
|
||||
case 0 -> 0;
|
||||
case 2 -> getChar(value, 0);
|
||||
default -> ArraysSupport.vectorizedHashCode(value, 0, value.length >> 1, 0, ArraysSupport.T_CHAR);
|
||||
};
|
||||
}
|
||||
|
||||
public static int indexOf(byte[] value, int ch, int fromIndex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2023, 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
|
||||
|
@ -2464,7 +2464,9 @@ public final class System {
|
|||
public String newStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException {
|
||||
return String.newStringNoRepl(bytes, cs);
|
||||
}
|
||||
|
||||
public char getUTF16Char(byte[] bytes, int index) {
|
||||
return StringUTF16.getChar(bytes, index);
|
||||
}
|
||||
public byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException {
|
||||
return String.getBytesNoRepl(s, cs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue