diff --git a/host/chez/collections.ss b/host/chez/collections.ss index 108bc6a..35936a5 100644 --- a/host/chez/collections.ss +++ b/host/chez/collections.ss @@ -239,11 +239,16 @@ ((string? coll) (let ((i (->idx k))) (if (and (fixnum? i) (fx>=? i 0) (fx (lambda (m) (jolt-invoke m coll k d))) + (else d))) + ((jrec-key=? (caar ps) k) (cdar ps)) + (else (loop (cdr ps))))))) ;; mutate a deftype's mutable field in place: the pairs are runtime cons cells, ;; so set-cdr! updates the field. (set! field v) inside a method ;; lowers to this; returns v, as set! does. @@ -77,12 +93,10 @@ ;; compiled to (get inst :field), never recurse); a NON-field key on a deftype that ;; implements clojure.lang.ILookup routes to its valAt (core.match's pattern types ;; compute ::tag in valAt), else the default. -(register-get-arm! jrec? - (lambda (coll k d) - (cond ((jrec-has? coll k) (jrec-lookup coll k d)) - ((find-method-any-protocol (jrec-tag coll) "valAt") - => (lambda (m) (jolt-invoke m coll k d))) - (else d)))) +;; jrec is the hottest get target (every record field read); jolt-get-dispatch +;; (collections.ss) checks jrec? directly and calls jrec-ref, skipping the get-arm +;; walk. This registration is the equivalent fallback for any other caller. +(register-get-arm! jrec? jrec-ref) ;; A jrec is a defrecord (map of fields) by default, BUT a deftype that ;; implements a clojure.lang collection interface carries the op as an inline ;; method — prefer that method, else fall back to the field/map behavior. (jrec-cl