From: Matt Birkholz Date: Wed, 1 Feb 2012 18:29:49 +0000 (-0700) Subject: cref: Replace alists with lists. X-Git-Tag: release-9.2.0~327 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d58912cd27169bc13c70298faa19edaa064f97f7;p=mit-scheme.git cref: Replace alists with lists. Even alists are too much when bindings and references already contain the name. Use find-matching-item rather than assq&cdr! --- diff --git a/src/cref/object.scm b/src/cref/object.scm index 5b95f4ac5..5a021d34e 100644 --- a/src/cref/object.scm +++ b/src/cref/object.scm @@ -59,8 +59,8 @@ USA. (files '()) parent (children '()) - (%bindings '()) - (%references '()) + (bindings '()) + (references '()) (links '())) (define-integrable (package/n-files package) @@ -70,26 +70,20 @@ USA. (null? (package/name package))) (define-integrable (package/find-reference package name) - (let ((entry (assq name (package/%references package)))) - (and entry (cdr entry)))) + (find-matching-item (package/references package) + (lambda (ref) (eq? (reference/name ref) name)))) -(define-integrable (package/put-reference! package name reference) - (set-package/%references! package (cons (cons name reference) - (package/%references package)))) +(define-integrable (package/put-reference! package reference) + (set-package/references! package + (cons reference (package/references package)))) (define-integrable (package/find-binding package name) - (let ((entry (assq name (package/%bindings package)))) - (and entry (cdr entry)))) - -(define-integrable (package/put-binding! package name binding) - (set-package/%bindings! package (cons (cons name binding) - (package/%bindings package)))) - -(define-integrable (package/bindings package) - (map cdr (package/%bindings package))) + (find-matching-item (package/bindings package) + (lambda (ref) (eq? (binding/name ref) name)))) -(define-integrable (package/references package) - (map cdr (package/%references package))) +(define-integrable (package/put-binding! package binding) + (set-package/bindings! package + (cons binding (package/bindings package)))) (define-integrable (file-case/type file-case) (car file-case)) diff --git a/src/cref/redpkg.scm b/src/cref/redpkg.scm index d8afa7c5c..b4e8a55e0 100644 --- a/src/cref/redpkg.scm +++ b/src/cref/redpkg.scm @@ -640,9 +640,7 @@ USA. destination-name (binding/value-cell source-binding) new?))) - (package/put-binding! destination-package - destination-name - binding) + (package/put-binding! destination-package binding) binding))) owner-package new?))) @@ -658,7 +656,7 @@ USA. (let ((binding (make-binding package name value-cell new?))) (set-value-cell/source-binding! value-cell binding) binding)))) - (package/put-binding! package name binding) + (package/put-binding! package binding) binding)))) (define (make-reference package name expression) @@ -677,6 +675,6 @@ USA. (add-reference! reference)) reference) (let ((reference (%make-reference package name))) - (package/put-reference! package name reference) + (package/put-reference! package reference) (add-reference! reference) reference))))) \ No newline at end of file