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.
This commit is contained in:
parent
e33ddda3bf
commit
e1d1aa69e8
1 changed files with 10 additions and 18 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue