| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughThis change removes unnecessary string conversions (such as .into(), .to_owned(), and .to_string()) from error message construction throughout the codebase. Error messages are now passed as string slices directly to exception constructors, and some function signatures are updated to accept any impl Into<String> type for error messages. No logic or control flow is altered. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ExceptionConstructor
Note over Caller,ExceptionConstructor: Previous flow
Caller->>ExceptionConstructor: new_type_error("msg".to_owned())
Note over Caller,ExceptionConstructor: New flow
Caller->>ExceptionConstructor: new_type_error("msg")
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review details Configuration used: CodeRabbit UI Reviewing files that changed from the base of the PR and between ebc88bc and 324b8be. 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ Share 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (.coderabbit.yaml)
Documentation and Community
|
Sorry, something went wrong.
| pub fn new_exception_msg( | ||
| &self, | ||
| exc_type: PyTypeRef, | ||
| msg: impl Into<String>, | ||
| ) -> PyBaseExceptionRef { | ||
| self.new_exception(exc_type, vec![self.ctx.new_str(msg.into()).into()]) |
There was a problem hiding this comment.
I couldn't find the issue but we once discussed about this changes. We needed a cut to to reduce binary size. I think most of new_*_error is simple wrappers of this function. Then reverting only this one and new_exception_msg_dict to using String will be good enough keep the balance of DX and having a single code to create params for new_exception.
Sorry, something went wrong.
There was a problem hiding this comment.
If one of the goals of the project is to reduce the binary size, I think this PR should be closed then.
I'm all for a clean, and better code as long as it's not hurting the goals of the project:)
If you think it's a good compromise then I'll implement your suggestions, but I'm afraid that you don't want to offend me by just closing the PR lol
Sorry, something went wrong.
There was a problem hiding this comment.
I think the most outer wrappers becomes more cleaner by your way. By only turning new_exception_msg and new_exception_msg_dict back to take only String, other changes will not affect binary size.
They are small functions, so must be inlined before.
Sorry, something went wrong.
There was a problem hiding this comment.
The binary sizes:
| target | main | branch | diff |
|---|---|---|---|
| debug | 226548kb (222M) | 226620kb (222M) | +72kb |
| relase | 21836kb (22M) | 21828kb (22M) | -8kb |
This change actually reduces the binary size on the release target? can you please verify that that's also the case on your machine?
Sorry, something went wrong.
There was a problem hiding this comment.
Interesting.
Build command: cargo build --release --no-default-features (because binary size tweaks usually wants less features)
It increased 17kb for me.
I rebased this patch on current main before build. My arch is aarch64-apple-darwin
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I built mine on aarch64-linux-android with cargo build (so with the default features).
I can recheck it without the default features, but I don't see the point in that as I assume the majority of RustPython users are not running on an android.
How should I proceed with this PR, if at all?
Sorry, something went wrong.
There was a problem hiding this comment.
I am good with reverting only new_exception_msg and new_exception_msg_dict but keeping anything else as you did.
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
There are a lot more places where we can remove the call of .to_owned(), but this is just a start.
Did it here for a couple of files just to show how much code we can remove.
Summary by CodeRabbit
Summary by CodeRabbit