mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8332826: Make hashCode methods in ArraysSupport friendlier
Reviewed-by: redestad, liach
This commit is contained in:
parent
2b4a4b7bd8
commit
3cff588a31
13 changed files with 234 additions and 80 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2024, 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
|
||||
|
@ -113,7 +113,7 @@ class CharacterName {
|
|||
}
|
||||
|
||||
private static int hashN(byte[] a, int off, int len) {
|
||||
return ArraysSupport.vectorizedHashCode(a, off, len, 1, ArraysSupport.T_BYTE);
|
||||
return ArraysSupport.hashCode(a, off, len, 1);
|
||||
}
|
||||
|
||||
private int addCp(int idx, int hash, int next, int cp) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, 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
|
||||
|
@ -303,11 +303,7 @@ final class StringLatin1 {
|
|||
}
|
||||
|
||||
public static int hashCode(byte[] value) {
|
||||
return switch (value.length) {
|
||||
case 0 -> 0;
|
||||
case 1 -> value[0] & 0xff;
|
||||
default -> ArraysSupport.vectorizedHashCode(value, 0, value.length, 0, ArraysSupport.T_BOOLEAN);
|
||||
};
|
||||
return ArraysSupport.hashCodeOfUnsigned(value, 0, value.length, 0);
|
||||
}
|
||||
|
||||
// Caller must ensure that from- and toIndex are within bounds
|
||||
|
|
|
@ -585,11 +585,7 @@ final class StringUTF16 {
|
|||
}
|
||||
|
||||
public static int hashCode(byte[] value) {
|
||||
return switch (value.length) {
|
||||
case 0 -> 0;
|
||||
case 2 -> getChar(value, 0);
|
||||
default -> ArraysSupport.vectorizedHashCode(value, 0, value.length >> 1, 0, ArraysSupport.T_CHAR);
|
||||
};
|
||||
return ArraysSupport.hashCodeOfUTF16(value, 0, value.length >> 1, 0);
|
||||
}
|
||||
|
||||
// Caller must ensure that from- and toIndex are within bounds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue