代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/openjdk-1.8.0 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From be90711b32cb79822222d31f258ff4e0f45a616c Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 15:24:07 +0800
Subject: add 8242842-Avoid-reallocating-name-when-checking-for-tr
---
.../share/classes/java/util/zip/ZipFile.java | 25 ++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/jdk/src/share/classes/java/util/zip/ZipFile.java b/jdk/src/share/classes/java/util/zip/ZipFile.java
index 9e854e84d..b6a6c2a48 100644
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java
@@ -1049,7 +1049,7 @@ class ZipFile implements ZipConstants, Closeable {
return h;
}
- private static final int hash_append(int hash, byte b) {
+ private static final int hashAppend(int hash, byte b) {
return hash * 31 + b;
}
@@ -1267,11 +1267,13 @@ class ZipFile implements ZipConstants, Closeable {
}
int hsh = hashN(name, 0, name.length);
int idx = table[(hsh & 0x7fffffff) % tablelen];
+ boolean appendSlash = false;
/*
* This while loop is an optimization where a double lookup
- * for name and name+/ is being performed. The name char
- * array has enough room at the end to try again with a
- * slash appended if the first table lookup does not succeed.
+ * for name and name+/ is being performed. The name byte
+ * array will be updated with an added slash only if the first
+ * table lookup fails and there is a matching hash value for
+ * name+/.
*/
while(true) {
/*
@@ -1282,6 +1284,11 @@ class ZipFile implements ZipConstants, Closeable {
if (getEntryHash(idx) == hsh) {
// The CEN name must match the specfied one
int pos = getEntryPos(idx);
+ if (appendSlash) {
+ name = Arrays.copyOf(name, name.length + 1);
+ name[name.length - 1] = '/';
+ appendSlash = false;
+ }
if (name.length == CENNAM(cen, pos)) {
boolean matched = true;
int nameoff = pos + CENHDR;
@@ -1302,11 +1309,11 @@ class ZipFile implements ZipConstants, Closeable {
if (!addSlash || name[name.length - 1] == '/') {
return -1;
}
- /* Add slash and try once more */
- name = Arrays.copyOf(name, name.length + 1);
- name[name.length - 1] = '/';
- hsh = hash_append(hsh, (byte)'/');
- //idx = table[hsh % tablelen];
+ // Add a slash to the hash code
+ hsh = hashAppend(hsh, (byte)'/');
+ // If we find a match on the new hash code, we need to append a
+ // slash when comparing
+ appendSlash = true;
idx = table[(hsh & 0x7fffffff) % tablelen];
addSlash = false;
}
--
2.22.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。