emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e1d1aa6: Convert CC Mode's c-found-types from an ob


From: Alan Mackenzie
Subject: [Emacs-diffs] master e1d1aa6: Convert CC Mode's c-found-types from an obarray to a hash table.
Date: Sun, 23 Jul 2017 09:52:01 -0400 (EDT)

branch: master
commit e1d1aa69e8cce480f51ebf81d5b0bb55c7ad4ec8
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Convert CC Mode's c-found-types from an obarray to a hash table.
    
    * lisp/progmodes/cc-engine.el (c-clear-found-types): create a hash table
    rather than an obarray.
    (c-copy-found-types): Remove.
    (c-add-type, c-unfind-type, c-check-type, c-list-found-types): Amend to use
    the new hash table.
    (c-forward-<>-arglist): Use copy-hash-table rather than c-copy-found-types.
---
 lisp/progmodes/cc-engine.el | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 22f5b90..59dc96a 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6089,14 +6089,8 @@ comment at the start of cc-engine.el for more info."
 
 (defsubst c-clear-found-types ()
   ;; Clears `c-found-types'.
-  (setq c-found-types (make-vector 53 0)))
-
-(defun c-copy-found-types ()
-  (let ((copy (make-vector 53 0)))
-    (mapatoms (lambda (sym)
-               (intern (symbol-name sym) copy))
-             c-found-types)
-    copy))
+  (setq c-found-types
+       (make-hash-table :test #'equal :weakness nil)))
 
 (defun c-add-type (from to)
   ;; Add the given region as a type in `c-found-types'.  If the region
@@ -6110,29 +6104,27 @@ comment at the start of cc-engine.el for more info."
   ;;
   ;; This function might do hidden buffer changes.
   (let ((type (c-syntactic-content from to c-recognize-<>-arglists)))
-    (unless (intern-soft type c-found-types)
-      (unintern (substring type 0 -1) c-found-types)
-      (intern type c-found-types))))
+    (unless (gethash type c-found-types)
+      (remhash (substring type 0 -1) c-found-types)
+      (puthash type t c-found-types))))
 
 (defun c-unfind-type (name)
   ;; Remove the "NAME" from c-found-types, if present.
-  (unintern name c-found-types))
+  (remhash name c-found-types))
 
 (defsubst c-check-type (from to)
   ;; Return non-nil if the given region contains a type in
   ;; `c-found-types'.
   ;;
   ;; This function might do hidden buffer changes.
-  (intern-soft (c-syntactic-content from to c-recognize-<>-arglists)
-              c-found-types))
+  (gethash (c-syntactic-content from to c-recognize-<>-arglists) 
c-found-types))
 
 (defun c-list-found-types ()
   ;; Return all the types in `c-found-types' as a sorted list of
   ;; strings.
   (let (type-list)
-    (mapatoms (lambda (type)
-               (setq type-list (cons (symbol-name type)
-                                     type-list)))
+    (maphash (lambda (type _)
+              (setq type-list (cons type type-list)))
              c-found-types)
     (sort type-list 'string-lessp)))
 
@@ -7066,7 +7058,7 @@ comment at the start of cc-engine.el for more info."
   ;; This function might do hidden buffer changes.
 
   (let ((start (point))
-       (old-found-types (c-copy-found-types))
+       (old-found-types (copy-hash-table c-found-types))
        ;; If `c-record-type-identifiers' is set then activate
        ;; recording of any found types that constitute an argument in
        ;; the arglist.



reply via email to

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