From 897fa22be48e50001e435af968e9bc7e7aa60683 Mon Sep 17 00:00:00 2001 From: Mikhail Kuzmin Date: Sun, 27 Oct 2024 23:02:44 +0400 Subject: [PATCH 1/2] call p/dependencies only once --- src/darkleaf/di/core.clj | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/darkleaf/di/core.clj b/src/darkleaf/di/core.clj index d0c01265..ad91a716 100644 --- a/src/darkleaf/di/core.clj +++ b/src/darkleaf/di/core.clj @@ -85,13 +85,16 @@ (conj tail (apply f head args)))) (defn- stack-frame [key dep-type factory] - {:key key - :dep-type dep-type - :factory factory - :remaining-deps (seq (p/dependencies factory))}) - -(defn- build-obj [built-map factory] - (let [declared-deps (p/dependencies factory) + (let [deps (p/dependencies factory)] + {:key key + :dep-type dep-type + :factory factory + :deps deps + :remaining-deps (seq deps)})) + +(defn- build-obj [built-map head] + (let [factory (:factory head) + declared-deps (:deps head) built-deps (select-keys built-map (keys declared-deps))] (p/build factory built-deps))) @@ -123,7 +126,7 @@ built-map)) :else - (let [obj (build-obj built-map factory) + (let [obj (build-obj built-map head) stop (bound-fn* #(p/demolish factory obj))] (vswap! *stop-list conj stop) (case [obj dep-type] From b2aba8ff840c2ae742baf3f2659abcd66936b3c0 Mon Sep 17 00:00:00 2001 From: Mikhail Kuzmin Date: Mon, 28 Oct 2024 12:08:08 +0400 Subject: [PATCH 2/2] name --- src/darkleaf/di/core.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/darkleaf/di/core.clj b/src/darkleaf/di/core.clj index ad91a716..6e55d8f2 100644 --- a/src/darkleaf/di/core.clj +++ b/src/darkleaf/di/core.clj @@ -89,12 +89,12 @@ {:key key :dep-type dep-type :factory factory - :deps deps + :declared-deps deps :remaining-deps (seq deps)})) (defn- build-obj [built-map head] (let [factory (:factory head) - declared-deps (:deps head) + declared-deps (:declared-deps head) built-deps (select-keys built-map (keys declared-deps))] (p/build factory built-deps)))