emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/osm 8f59df8fbf 3/5: Use hash table for pins


From: ELPA Syncer
Subject: [elpa] externals/osm 8f59df8fbf 3/5: Use hash table for pins
Date: Mon, 7 Mar 2022 12:57:57 -0500 (EST)

branch: externals/osm
commit 8f59df8fbfb84b946787dc8d83317fb1f2af87de
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Use hash table for pins
---
 osm.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/osm.el b/osm.el
index 15a16efce2..b9397848c2 100644
--- a/osm.el
+++ b/osm.el
@@ -224,7 +224,7 @@ Should be at least 7 days according to the server usage 
policies."
   "X coordinate on the map in pixel.")
 
 (defvar-local osm--pins nil
-  "Pin positions.")
+  "Pin hash table.")
 
 (defvar-local osm--transient-pin nil
   "Transient pin.")
@@ -545,11 +545,11 @@ Should be at least 7 days according to the server usage 
policies."
   (add-hook 'window-size-change-functions #'osm--resize nil 'local))
 
 (defun osm--put-pin (x y color)
-  "Put pin at X/Y with COLOR in pins alist."
+  "Put pin at X/Y with COLOR in pins hash table."
   (let ((x0 (/ x 256))
         (y0 (/ y 256)))
     (push `(,color ,(- x (* x0 256)) . ,(- y (* y0 256)))
-          (alist-get y0 (alist-get x0 osm--pins)))
+          (gethash (cons x0 y0) osm--pins))
     (cl-loop
      for i from -1 to 1 do
      (cl-loop
@@ -558,11 +558,11 @@ Should be at least 7 days according to the server usage 
policies."
             (y1 (/ (+ y (* 64 j)) 256)))
         (unless (and (= x0 x1) (= y0 y1))
           (push `(,color ,(- x (* x1 256)) . ,(- y (* y1 256)))
-                (alist-get y1 (alist-get x1 osm--pins)))))))))
+                (gethash (cons x1 y1) osm--pins))))))))
 
 (defun osm--compute-pins ()
   "Compute pin positions."
-  (setq osm--pins nil)
+  (setq osm--pins (make-hash-table :test #'equal))
   (when osm--transient-pin
     (osm--put-pin osm--x osm--y "#ff0088"))
   (bookmark-maybe-load-default-file)
@@ -586,7 +586,7 @@ Should be at least 7 days according to the server usage 
policies."
     (when (file-exists-p file)
       `(image
         :width 256 :height 256
-        ,@(if-let (pins (alist-get y (alist-get x osm--pins)))
+        ,@(if-let (pins (gethash (cons x y) osm--pins))
               (list :type 'svg :base-uri file
                     :data (concat "<svg width='256' height='256' version='1.1'
 xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]