Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# http://editorconfig.org/

[*]
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf

[*.clj]
max_line_length = 120

[*.{html,css,mustache,js,jsx,ts,tsx,json}]
indent_size = 2

[*.{yaml,yml}]
indent_size = 2
6 changes: 4 additions & 2 deletions src/methodical/impl/combo/threaded.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
([threader before-primary-afters]
(comp (reducer-fn before-primary-afters) threader))

([threader primary-methods {:keys [before after around]}]
([threader primary-methods {:keys [before after around], :as aux-methods}]
(when-let [primary (combo.common/combine-primary-methods primary-methods)]
(let [methods (concat before [primary] (reverse after))
threaded-fn (combine-with-threader threader methods)
Expand All @@ -39,7 +39,9 @@
([a b c] (threaded-fn a b c))
([a b c d] (threaded-fn a b c d))
([a b c d & more] (apply threaded-fn a b c d more)))
(vary-meta assoc :methodical/combined-method? true))
(vary-meta assoc
:methodical/combined-method? true
:methodical/built-from {:primary primary-methods, :aux aux-methods}))
around)))))

(defmulti threading-invoker
Expand Down
7 changes: 4 additions & 3 deletions src/methodical/impl/multifn/cached.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
;; cache for dispatch value. This way we don't end up with a bunch of duplicate methods impls for various
;; dispatch values that have the same effective dispatch value
cached-effective-dv-method (.cached-method cache effective-dispatch-value)
method (or cached-effective-dv-method method)]
method (-> (or cached-effective-dv-method method)
(vary-meta assoc :methodical/cached-by dispatch-value))]
;; Make sure the method was cached for the effective dispatch value as well, that way if some less-specific
;; dispatch value comes along with the same effective dispatch value we can use the existing method
(when-not cached-effective-dv-method
(i/cache-method! cache effective-dispatch-value method))
(i/cache-method! cache dispatch-value method)
(i/cache-method! cache effective-dispatch-value (vary-meta method assoc :methodical/cached-for effective-dispatch-value)))
(i/cache-method! cache dispatch-value (vary-meta method assoc :methodical/cached-for dispatch-value))
method))))
4 changes: 3 additions & 1 deletion src/methodical/impl/multifn/standard.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
(let [primary-methods (i/matching-primary-methods dispatcher method-table dispatch-value)
aux-methods (i/matching-aux-methods dispatcher method-table dispatch-value)]
(some-> (i/combine-methods method-combination primary-methods aux-methods)
(with-meta {:dispatch-value (effective-dispatch-value dispatcher dispatch-value primary-methods aux-methods)}))))
(with-meta {:dispatch-value (effective-dispatch-value dispatcher dispatch-value primary-methods aux-methods)
:methodical/built-for dispatch-value
:methodical/built-from {:primary primary-methods, :aux aux-methods}}))))

(p.types/deftype+ StandardMultiFnImpl [^MethodCombination combo
^Dispatcher dispatcher
Expand Down