]> git.eshelyaron.com Git - emacs.git/commitdiff
Convert CC Mode's c-found-types from an obarray to a hash table.
authorAlan Mackenzie <acm@muc.de>
Sun, 23 Jul 2017 13:48:36 +0000 (13:48 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 23 Jul 2017 13:48:36 +0000 (13:48 +0000)
* 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

index 22f5b906e4e891fee4fe2034ee73d40df7bf55dc..59dc96af03092c56649b00be2b8556211baa54af 100644 (file)
@@ -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.