-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve combine
to not return lazy sequences
#304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,9 +76,9 @@ | |
(cond | ||
(-> newval meta :replace) newval | ||
(and (map? curr) (map? newval)) (merge-with combine curr newval) | ||
(and (list? curr) (coll? newval)) (concat curr newval) | ||
(and (vector? curr) (coll? newval)) (concat curr newval) | ||
(and (set? curr) (coll? newval)) (set (concat curr newval)) | ||
(and (list? curr) (coll? newval)) (apply list (concat curr newval)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My reasoning was to preserve backwards compatibility for insertion order.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch! Do we have a test for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the current test fails otherwise. |
||
(and (vector? curr) (coll? newval)) (into curr newval) | ||
(and (set? curr) (coll? newval)) (into curr newval) | ||
:otherwise newval)) | ||
|
||
(defn is-protocol-exception? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think combining to a lazy sequence in general is not bad. We just need to be sure that we don't make lazy results where not expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe for another PR! I'm also not sure the best way to check for a lazy seq, since
seq?
also returns true for lists.