Skip to content
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

Optimizing conj and assoc and making their behavior match clj's more closely #17

Merged
merged 10 commits into from
Aug 15, 2022

Conversation

corasaurus-hex
Copy link
Collaborator

@corasaurus-hex corasaurus-hex commented Aug 14, 2022

These appear to be significantly faster than the original functions and handle more corner cases in order to more closely match clojure's conj/assoc functions.

EDIT: I added get + assoc-in + assoc-in! as a bonus on this PR, and sped up str / added tests for it.

@corasaurus-hex corasaurus-hex changed the title WIP optimizing conj and assoc and making their behavior more match clj's Optimizing conj and assoc and making their behavior match clj's more closely Aug 15, 2022
@borkdude
Copy link
Member

borkdude commented Aug 15, 2022

Appreciate this PR! Thanks a lot. I do prefer to work in small PRs that don't add a ton of stuff in one go, so it's easier to review.

About assoc-in we have a separate issue and I think we should first discuss if assoc-in should make clones of each object, or update them in place. This is an important decision that needs some thought instead of slipping it through in a PR I think?

About prettier: why is let res = f(ctr,x); better than let res = f(ctr, x);?
And return n+1; is changed into return n + 1, where is the consistency in that?

cc @lilactown

@borkdude
Copy link
Member

Did some benchmarking and found that using an imperative counter is faster than using for (x in xs):

https://jsbench.me/cbl6ujmp3d/1

@lilactown lilactown mentioned this pull request Aug 15, 2022
@borkdude borkdude merged commit 5199abf into squint-cljs:main Aug 15, 2022
borkdude added a commit that referenced this pull request Dec 24, 2022
…closely (#17)

* WIP optimizing conj and assoc and making their behavior more match clj's

* fix conj tests

* fix calling namespace on non-kw in map emit

* Fix some bugs in assoc/conj and add more tests for them

* Fill out the remainder of tests and fix more bugs

* Remove some prettier formatting that was accidentally applied

* Bonus get + assoc-in + assoc-in!

* Added tests for str and optimized it.

Co-authored-by: Will Acton <will@willacton.com>
Co-authored-by: Michiel Borkent <michielborkent@gmail.com>
wearethebork pushed a commit that referenced this pull request Dec 25, 2022
borkdude added a commit that referenced this pull request Dec 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants