Skip to content

fix: reduce the amount of useless allocations for errors on hot paths - #2369

Open
Ddystopia wants to merge 1 commit into
pgcentralfoundation:developfrom
Ddystopia:develop
Open

Ddystopia wants to merge 1 commit into
pgcentralfoundation:developfrom
Ddystopia:develop

Conversation

@Ddystopia

@Ddystopia Ddystopia commented Sep 4, 2026

Copy link
Copy Markdown

Hi, I noticed a bunch of strange allocations on my hot path and it turned out to be some .ok_or(SpiError::CursorNotFound(name.to_string()))? at pgrx/src/spi/client.rs:159, which was immediately dropped. I became upset and told claude to find all similar places there and make them like they should be, in ok_or_else and similar. I reviewed the code and I believe it is fine - and the changes are trivial.

@0xPoe 0xPoe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should consider enabling the or_fun_call lint if we accept these changes?

@Ddystopia

Copy link
Copy Markdown
Author

It depends on what exactly you want. There were many cases of ok_or(something_static), or similar. If it will get flagged, I am concerned about developer experience, as the code will become uglier.

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