-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
perf: avoid mem alloc in formatting, minor bug fix #1521
Conversation
I don't see how the code could function with that being the case, so it seems possible this has just moved the bug around. I will have to take a closer look. |
Optimize writing formatted string to Serde, bypassing string allocations when possible. Note that `pgrx-sql-entity-graph/src/extension_sql/entity.rs` seemed to have a bug for Function printing - it was printing `Function name)` without the opening parenthesis. Also, in a few spots, I replaced `buffer.write_fmt(format_args!(...))` with `write!(buffer, ...)` -- as that's exactly what `write!` macro is for.
} | ||
SqlDeclaredEntity::Function(data) => { | ||
f.write_str(&(String::from("Function ") + &data.name + ")")) | ||
write!(f, "Function({})", data.name) |
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 can't actually find a case where this actually diffs a schema, and that is Worrying, because that suggests it is Simply Dead Code.
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 did not exhaustively cover every extension in reach but I have reached the "I need to script out the schema generation delta check" part, which means I might as well bash out a v0.1 solution to #1521
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.
This looks good to me. In addition to cutting out unnecessary allocations, this also makes the affected code more readable.
any updates on this? |
Optimize writing formatted string to Serde, bypassing string allocations when possible.
Note that
pgrx-sql-entity-graph/src/extension_sql/entity.rs
seemed to have a bug for Function printing - it was printingFunction name)
without the opening parenthesis.Also, in a few spots, I replaced
buffer.write_fmt(format_args!(...))
withwrite!(buffer, ...)
-- as that's exactly whatwrite!
macro is for.