]> Sergey Matveev's repositories - zk.zsh.git/commitdiff
Simpler deduplication
authorSergey Matveev <stargrave@stargrave.org>
Sun, 13 Mar 2022 10:36:21 +0000 (13:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 13 Mar 2022 10:36:21 +0000 (13:36 +0300)
zk.zsh

diff --git a/zk.zsh b/zk.zsh
index 5a46d999208819990a59ed9c152d83c38debec84..5326cb08b0f3e5d18cc6adf7807f24a14395d99a 100755 (executable)
--- a/zk.zsh
+++ b/zk.zsh
@@ -34,19 +34,14 @@ for p (${(k)pages}) {
 }
 
 # Deduplicate all references
-typeset -A ws
 for p (${(k)links}) {
-    ws=()
-    for w (${=${links[$p]}}) {
-        ws[$w]=1
-        backs[$w]="$p ${backs[$w]}"
-    }
-    links[$p]=${(k)ws}
+    local ws=(${(u)=links[$p]})
+    links[$p]=${(j: :)ws}
+    for w ($ws) backs[$w]="$p ${backs[$w]}"
 }
 for p (${(k)backs}) {
-    ws=()
-    for w (${=${backs[$p]}}) ws[$w]=1
-    backs[$p]=${(k)ws}
+    local ws=(${(u)=backs[$p]})
+    backs[$p]=${(j: :)ws}
 }
 
 autoload -U relative