From c2bc202a8dae963472d8c9b05a74fa0c2eede322 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Sun, 11 Oct 2026 03:03:46 +0800 Subject: [PATCH] docs: update Go map implementation for Go 1.24 (#1974) * docs: update Go map implementation for Go 1.24 * docs: keep Swiss Table wording unlinked across translations * docs(ja): align open addressing terminology with the chapter --- docs/chapter_hashing/hash_collision.md | 2 +- en/docs/chapter_hashing/hash_collision.md | 2 +- ja/docs/chapter_hashing/hash_collision.md | 2 +- ru/docs/chapter_hashing/hash_collision.md | 2 +- zh-hant/docs/chapter_hashing/hash_collision.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/chapter_hashing/hash_collision.md b/docs/chapter_hashing/hash_collision.md index a1a1fd576..f964b5453 100644 --- a/docs/chapter_hashing/hash_collision.md +++ b/docs/chapter_hashing/hash_collision.md @@ -105,4 +105,4 @@ - Python 采用开放寻址。字典 `dict` 使用伪随机数进行探测。 - Java 采用链式地址。自 JDK 1.8 以来,当 `HashMap` 内数组长度达到 64 且链表长度达到 8 时,链表会转换为红黑树以提升查找性能。 -- Go 采用链式地址。Go 规定每个桶最多存储 8 个键值对,超出容量则连接一个溢出桶;当溢出桶过多时,会执行一次特殊的等量扩容操作,以确保性能。 +- Go 1.24 起,内置 `map` 默认采用基于 Swiss Table 的开放寻址实现。Go 1.23 及更早版本采用链式地址,每个桶最多存储 8 个键值对,超出容量时连接溢出桶。 diff --git a/en/docs/chapter_hashing/hash_collision.md b/en/docs/chapter_hashing/hash_collision.md index a21c08c2f..e2661fb7a 100644 --- a/en/docs/chapter_hashing/hash_collision.md +++ b/en/docs/chapter_hashing/hash_collision.md @@ -105,4 +105,4 @@ Different programming languages adopt different hash table implementation strate - Python uses open addressing. The `dict` dictionary uses pseudo-random numbers for probing. - Java uses separate chaining. Since JDK 1.8, when the array length in `HashMap` reaches 64 and the length of a linked list reaches 8, the linked list is converted to a red-black tree to improve search performance. -- Go uses separate chaining. Go stipulates that each bucket can store up to 8 key-value pairs, and if the capacity is exceeded, an overflow bucket is linked; when there are too many overflow buckets, a special equal-capacity expansion operation is performed to ensure performance. +- Starting with Go 1.24, the built-in `map` uses an open-addressed implementation based on Swiss Tables by default. Go 1.23 and earlier use separate chaining, with up to 8 key-value pairs per bucket and overflow buckets linked when that capacity is exceeded. diff --git a/ja/docs/chapter_hashing/hash_collision.md b/ja/docs/chapter_hashing/hash_collision.md index 823c23e79..7fbc767fc 100644 --- a/ja/docs/chapter_hashing/hash_collision.md +++ b/ja/docs/chapter_hashing/hash_collision.md @@ -105,4 +105,4 @@ - Python はオープンアドレッシングを採用しています。辞書 `dict` は疑似乱数を用いて探索します。 - Java はチェイン法を採用しています。JDK 1.8 以降、`HashMap` 内の配列長が 64 に達し、かつ連結リスト長が 8 に達すると、連結リストは検索性能を高めるため赤黒木に変換されます。 -- Go はチェイン法を採用しています。Go では各バケットに最大 8 個のキーと値のペアを格納でき、容量を超えるとオーバーフローバケットを連結します。オーバーフローバケットが多すぎる場合は、性能を確保するために特殊な等量拡張操作を実行します。 +- Go 1.24 以降、組み込みの `map` はデフォルトで Swiss Table に基づくオープンアドレッシングの実装を採用しています。Go 1.23 以前はチェイン法を採用し、各バケットに最大 8 個のキーと値のペアを格納し、容量を超えるとオーバーフローバケットを連結します。 diff --git a/ru/docs/chapter_hashing/hash_collision.md b/ru/docs/chapter_hashing/hash_collision.md index 248cb0c35..a6aabfc52 100644 --- a/ru/docs/chapter_hashing/hash_collision.md +++ b/ru/docs/chapter_hashing/hash_collision.md @@ -105,4 +105,4 @@ - Python использует открытую адресацию. В словаре `dict` для пробирования применяются псевдослучайные числа. - Java использует метод цепочек. Начиная с JDK 1.8, когда длина массива внутри `HashMap` достигает 64, а длина списка достигает 8, этот список преобразуется в красно-черное дерево для повышения производительности поиска. -- Go использует метод цепочек. В Go установлено, что каждый бакет может хранить не более 8 пар ключ-значение. При переполнении подключается overflow-бакет, а когда таких бакетов становится слишком много, выполняется специальное расширение того же масштаба, чтобы сохранить производительность. +- Начиная с Go 1.24, встроенный `map` по умолчанию использует реализацию с открытой адресацией на основе Swiss Table. В Go 1.23 и более ранних версиях используется метод цепочек: каждый бакет вмещает до 8 пар ключ-значение, а при превышении этой вместимости к нему присоединяется overflow-бакет. diff --git a/zh-hant/docs/chapter_hashing/hash_collision.md b/zh-hant/docs/chapter_hashing/hash_collision.md index 1939cd24c..e74ee13a8 100644 --- a/zh-hant/docs/chapter_hashing/hash_collision.md +++ b/zh-hant/docs/chapter_hashing/hash_collision.md @@ -105,4 +105,4 @@ - Python 採用開放定址。字典 `dict` 使用偽隨機數進行探測。 - Java 採用鏈式位址。自 JDK 1.8 以來,當 `HashMap` 內陣列長度達到 64 且鏈結串列長度達到 8 時,鏈結串列會轉換為紅黑樹以提升查詢效能。 -- Go 採用鏈式位址。Go 規定每個桶最多儲存 8 個鍵值對,超出容量則連線一個溢位桶;當溢位桶過多時,會執行一次特殊的等量擴容操作,以確保效能。 +- Go 1.24 起,內建 `map` 預設採用基於 Swiss Table 的開放定址實現。Go 1.23 及更早版本採用鏈式位址,每個桶最多儲存 8 個鍵值對,超出容量時連線溢位桶。