Changeset 9505


Ignore:
Timestamp:
May 16, 2008, 12:51:10 AM (11 years ago)
Author:
gb
Message:

Use (typep x 'hash-table) instead of (hash-table-p x). Mostly because
we can, but may be a little faster.

There's an (unresolved) issue related to the definition of type-predicates
on ISTRUCT classes that have no subclasses: in the TYPEP compiler-macro,
it's generally better to recognize the istruct class and do an inline
ISTRUCT-TYPEP than it is to call a function that does that; at compile-time,
we can certainly afford a FIND-CLASS. At runtime (in #'TYPEP), calling
a predicate if it exists is likely to be much, much cheaper than going
through translation/%typep would be. I started to remove type-predicates
on simple istruct classes before realizing this; it may be better to
keep them around and re-work OPTIMIZE-TYPEP to try the simple istruct
class case first.

In any case, (typep x 'hash-table-p) and (hash-table-p x) should ideally
be equivalent in all respects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711-perf/ccl/level-0/l0-hash.lisp

    r8605 r9505  
    615615  "This removes all the entries from HASH-TABLE and returns the hash table
    616616   itself."
    617   (unless (hash-table-p hash)
     617  (unless (typep hash 'hash-table)
    618618    (report-bad-arg hash 'hash-table))
    619619  (with-lock-context
     
    699699   value and T as multiple values, or returns DEFAULT and NIL if there is no
    700700   such entry. Entries can be added using SETF."
    701   (unless (hash-table-p hash)
     701  (unless (typep hash 'hash-table)
    702702    (report-bad-arg hash 'hash-table))
    703703  (let* ((value nil)
     
    749749  "Remove the entry in HASH-TABLE associated with KEY. Return T if there
    750750   was such an entry, or NIL if not."
    751   (unless (hash-table-p hash)
     751  (unless (typep hash 'hash-table)
    752752    (setq hash (require-type hash 'hash-table)))
    753753  (let* ((foundp nil))
     
    808808(defun puthash (key hash default &optional (value default))
    809809  (declare (optimize (speed 3) (space 0)))
    810   (unless (hash-table-p hash)
     810  (unless (typep hash 'hash-table)
    811811    (report-bad-arg hash 'hash-table))
    812812  (if (eq key (%unbound-marker))
     
    884884
    885885(defun grow-hash-table (hash)
    886   (unless (hash-table-p hash)
     886  (unless (typep hash 'hash-table)
    887887    (setq hash (require-type hash 'hash-table)))
    888888  (%grow-hash-table hash))
     
    15751575                     (return (values hash address-p)))
    15761576                   (setq key (cdr key)))))
    1577               ((hash-table-p key)
     1577              ((typep key 'hash-table)
    15781578               (equalphash-hash-table key))
    15791579              ; what are the dudes called that contain bits? they are uvectors but not gvectors?
     
    16881688
    16891689(defun assert-hash-table-readonly (hash)
    1690   (unless (hash-table-p hash)
     1690  (unless (typep hash 'hash-table)
    16911691    (report-bad-arg hash 'hash-table))
    16921692  (or (nhash.read-only hash)
     
    17101710;; hash table. Use it responsibly.
    17111711(defun assert-hash-table-writeable (hash)
    1712   (unless (hash-table-p hash)
     1712  (unless (typep hash 'hash-table)
    17131713    (report-bad-arg hash 'hash-table))
    17141714  (when (nhash.read-only hash)
     
    17171717
    17181718(defun readonly-hash-table-p (hash)
    1719   (unless (hash-table-p hash)
     1719  (unless (typep hash 'hash-table)
    17201720    (report-bad-arg hash 'hash-table))
    17211721  (nhash.read-only hash))
    17221722
    17231723(defun hash-table-owner (hash)
    1724   (unless (hash-table-p hash)
     1724  (unless (typep hash 'hash-table)
    17251725    (report-bad-arg hash 'hash-table))
    17261726  (nhash.owner hash))
    17271727
    17281728(defun claim-hash-table (hash &optional steal)
    1729   (unless (hash-table-p hash)
     1729  (unless (typep hash 'hash-table)
    17301730    (report-bad-arg hash 'hash-table))
    17311731  (let* ((owner (nhash.owner hash)))
     
    17451745
    17461746(defun enumerate-hash-keys (hash out)
    1747   (unless (hash-table-p hash)
     1747  (unless (typep hash 'hash-table)
    17481748    (report-bad-arg hash 'hash-table))
    17491749  (with-lock-context
     
    17671767
    17681768(defun enumerate-hash-keys-and-values (hash keys values)
    1769   (unless (hash-table-p hash)
     1769  (unless (typep hash 'hash-table)
    17701770    (report-bad-arg hash 'hash-table))
    17711771  (with-lock-context
Note: See TracChangeset for help on using the changeset viewer.