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

chore: remove most impl AsRef<str,Path> #157

Merged
merged 7 commits into from
Jun 28, 2024
Merged

chore: remove most impl AsRef<str,Path> #157

merged 7 commits into from
Jun 28, 2024

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Jun 28, 2024

These mostly only bloat code size and compilation times, which are already not great when we are already codegenning a billion structs and ASTs with serde derives

For AsRef, the only change is having to specify an extra 1 (one) character (&) when using String so it derefs to str, otherwise it's the same

For AsRef it's the same as AsRef when using Path/PathBuf, but it's a bit worse for string literals; but most of these functions are called with variables in the first place. except in tests which will have to use .as_ref() or Path::new

I've not removed these when using with &[] or impl IntoIterator since that does help quite a bit, e.g if you have an owning iterator of Strings, you cannot borrow inside of a map closure

I've also kept Into since that makes more sense, you want to avoid cloning if you can pass in an owned thing already, otherwise you'll clone it yourself

Also fixes some inconsistencies in function signatures for str vs path

@DaniPopes DaniPopes requested a review from Evalir as a code owner June 28, 2024 18:01
@DaniPopes DaniPopes requested review from mattsse and klkvr June 28, 2024 18:05
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasonable, ty!

I assume we need to update a few calls in foundry after we release this

@DaniPopes
Copy link
Member Author

Pending github waking up and running actions

@DaniPopes DaniPopes force-pushed the dani/rm-impl-asref branch from 0d71b66 to 134a307 Compare June 28, 2024 21:30
@DaniPopes DaniPopes merged commit bc96471 into main Jun 28, 2024
15 checks passed
@DaniPopes DaniPopes deleted the dani/rm-impl-asref branch June 28, 2024 22:20
ziminq added a commit to ziminq/foundry-compilers that referenced this pull request Sep 4, 2024
Due to the this commit:

commit bc96471
Author: DaniPopes <[email protected]>
Date:   Sat Jun 29 00:20:26 2024 +0200

    chore: remove most impl AsRef<str,Path> (foundry-rs#157)

The interface for `hardhat()` is updated to `&Path`.
mattsse pushed a commit that referenced this pull request Sep 4, 2024
Due to the this commit:

commit bc96471
Author: DaniPopes <[email protected]>
Date:   Sat Jun 29 00:20:26 2024 +0200

    chore: remove most impl AsRef<str,Path> (#157)

The interface for `hardhat()` is updated to `&Path`.

---------

Co-authored-by: DaniPopes <[email protected]>
klkvr pushed a commit that referenced this pull request Sep 16, 2024
Due to the this commit:

commit bc96471
Author: DaniPopes <[email protected]>
Date:   Sat Jun 29 00:20:26 2024 +0200

    chore: remove most impl AsRef<str,Path> (#157)

The interface for `hardhat()` is updated to `&Path`.

---------

Co-authored-by: DaniPopes <[email protected]>
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.

2 participants