@@ -8244,37 +8244,38 @@ Use `verilog-preserve-modi-cache' to set it.")
8244
8244
;; return
8245
8245
(vector name (or (buffer-file-name) (current-buffer)) pt)))
8246
8246
8247
- (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.")
8248
- (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.")
8249
- (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.")
8250
- (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.")
8247
+ (defvar verilog-modi-lookup-cache nil "Hash of (modulename modi).")
8248
+ (defvar verilog-modi-lookup-last-current nil "Cache of `current-buffer' at last lookup.")
8249
+ (defvar verilog-modi-lookup-last-tick nil "Cache of `buffer-modified-tick' at last lookup.")
8251
8250
8252
8251
(defun verilog-modi-lookup (module allow-cache &optional ignore-error)
8253
8252
"Find the file and point at which MODULE is defined.
8254
8253
If ALLOW-CACHE is set, check and remember cache of previous lookups.
8255
8254
Return modi if successful, else print message unless IGNORE-ERROR is true."
8256
- (let* ((current (or (buffer-file-name) (current-buffer))))
8257
- (cond ((and verilog-modi-lookup-last-modi
8255
+ (let* ((current (or (buffer-file-name) (current-buffer)))
8256
+ modi)
8257
+ ;; Check cache
8258
+ ;;(message "verilog-modi-lookup: %s" module)
8259
+ (cond ((and verilog-modi-lookup-cache
8258
8260
verilog-cache-enabled
8259
8261
allow-cache
8260
- (equal verilog-modi-lookup-last-mod module )
8262
+ (setq modi (gethash module verilog-modi-lookup-cache) )
8261
8263
(equal verilog-modi-lookup-last-current current)
8262
8264
;; Iff hit is in current buffer, then tick must match
8263
8265
(or (equal verilog-modi-lookup-last-tick (buffer-modified-tick))
8264
- (not (equal current (verilog-modi-file-or-buffer
8265
- verilog-modi-lookup-last- modi)))) )
8266
- ;; ok as is
8267
- )
8266
+ (not (equal current (verilog-modi-file-or-buffer modi)))))
8267
+ ;;(message " verilog-modi-lookup: HIT %S" modi)
8268
+ modi)
8269
+ ;; Miss
8268
8270
(t (let* ((realmod (verilog-symbol-detick module t))
8269
8271
(orig-filenames (verilog-module-filenames realmod current))
8270
8272
(filenames orig-filenames)
8271
8273
pt)
8272
8274
(while (and filenames (not pt))
8273
8275
(if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames))))
8274
8276
(setq filenames (cdr filenames))))
8275
- (cond (pt (setq verilog-modi-lookup-last-modi
8276
- (vector realmod (car filenames) pt)))
8277
- (t (setq verilog-modi-lookup-last-modi nil)
8277
+ (cond (pt (setq modi (vector realmod (car filenames) pt)))
8278
+ (t (setq modi nil)
8278
8279
(or ignore-error
8279
8280
(error (concat (verilog-point-text)
8280
8281
": Can't locate " module " module definition"
@@ -8284,10 +8285,14 @@ Return modi if successful, else print message unless IGNORE-ERROR is true."
8284
8285
"\n Check the verilog-library-directories variable."
8285
8286
"\n I looked in (if not listed, doesn't exist):\n\t"
8286
8287
(mapconcat 'concat orig-filenames "\n\t"))))))
8287
- (setq verilog-modi-lookup-last-mod module
8288
- verilog-modi-lookup-last-current current
8288
+ (when (eval-when-compile (fboundp 'make-hash-table))
8289
+ (unless verilog-modi-lookup-cache
8290
+ (setq verilog-modi-lookup-cache
8291
+ (make-hash-table :test 'equal :rehash-size 4.0)))
8292
+ (puthash module modi verilog-modi-lookup-cache))
8293
+ (setq verilog-modi-lookup-last-current current
8289
8294
verilog-modi-lookup-last-tick (buffer-modified-tick)))))
8290
- verilog-modi-lookup-last- modi))
8295
+ modi))
8291
8296
8292
8297
(defsubst verilog-modi-name (modi)
8293
8298
(aref modi 0))
0 commit comments