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

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

[nongnu] elpa/pacmacs b00db2f7fa 240/472: Use hashmap for tile cache ins


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs b00db2f7fa 240/472: Use hashmap for tile cache instead of vector (#131)
Date: Thu, 6 Jan 2022 21:59:28 -0500 (EST)

branch: elpa/pacmacs
commit b00db2f7fa852bc64bedca43e11535577d2fd6ce
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>

    Use hashmap for tile cache instead of vector (#131)
---
 pacmacs-image.el | 58 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/pacmacs-image.el b/pacmacs-image.el
index faf4443b32..0d5e28953c 100644
--- a/pacmacs-image.el
+++ b/pacmacs-image.el
@@ -35,7 +35,8 @@
 (require 'dash)
 
 (defconst pacmacs--flip-xbm-bits (eq system-type 'windows-nt))
-(defvar pacmacs--wall-blocks (make-vector 256 nil))
+(defvar pacmacs--wall-blocks
+  (make-hash-table))
 
 (defun pacmacs-load-image (filename)
   (create-image filename 'xpm nil :heuristic-mask t))
@@ -91,43 +92,44 @@
           (list bottom right top left
                 left-upper right-upper
                 left-bottom right-bottom))))
-    (-if-let (cached-tile (aref pacmacs--wall-blocks cache-index))
+    (-if-let (cached-tile (gethash cache-index pacmacs--wall-blocks))
         cached-tile
-      (aset pacmacs--wall-blocks cache-index
-            (let ((wall-block (make-vector
-                               width nil))
-                  (weight 3))
+      (puthash cache-index
+               (let ((wall-block (make-vector
+                                  width nil))
+                     (weight 3))
 
-              (dotimes (i width)
-                (aset wall-block i (make-bool-vector height nil)))
+                 (dotimes (i width)
+                   (aset wall-block i (make-bool-vector height nil)))
 
-              (when left-upper
-                (pacmacs--put-bits-dot wall-block 0 0 weight))
+                 (when left-upper
+                   (pacmacs--put-bits-dot wall-block 0 0 weight))
 
-              (when right-upper
-                (pacmacs--put-bits-dot wall-block 0 (- width weight) weight))
+                 (when right-upper
+                   (pacmacs--put-bits-dot wall-block 0 (- width weight) 
weight))
 
-              (when left-bottom
-                (pacmacs--put-bits-dot wall-block (- height weight) 0 weight))
+                 (when left-bottom
+                   (pacmacs--put-bits-dot wall-block (- height weight) 0 
weight))
 
-              (when right-bottom
-                (pacmacs--put-bits-dot wall-block (- height weight) (- width 
weight) weight))
+                 (when right-bottom
+                   (pacmacs--put-bits-dot wall-block (- height weight) (- 
width weight) weight))
 
-              (when left
-                (pacmacs--put-vertical-bar wall-block 0 height weight))
+                 (when left
+                   (pacmacs--put-vertical-bar wall-block 0 height weight))
 
-              (when right
-                (pacmacs--put-vertical-bar wall-block (- width weight) height 
weight))
+                 (when right
+                   (pacmacs--put-vertical-bar wall-block (- width weight) 
height weight))
 
-              (when top
-                (pacmacs--put-horizontal-bar wall-block 0 width weight))
-              
-              (when bottom
-                (pacmacs--put-horizontal-bar wall-block (- height weight) 
width weight))
+                 (when top
+                   (pacmacs--put-horizontal-bar wall-block 0 width weight))
+                 
+                 (when bottom
+                   (pacmacs--put-horizontal-bar wall-block (- height weight) 
width weight))
 
-              (create-image wall-block 'xbm t :width width :height height
-                            :foreground color
-                            :background nil))))))
+                 (create-image wall-block 'xbm t :width width :height height
+                               :foreground color
+                               :background nil))
+               pacmacs--wall-blocks))))
 
 (defun pacmacs-create-transparent-block (width height)
   (create-image



reply via email to

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