-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
RawArray::from_ptr
a simple cast (#1587)
I have been working on the DetoastDatum implementation, and because our ArrayType wrappers happen to exercise a lot of parts of pgrx while being something I understand very well, I am aiming to ship its MVP with Yet Another improvement on `pgrx::datum::Array` that will be a model for future safe abstractions of Datum-derived types. This will involve quite a lot of work with RawArray and the code that is currently living next to RawArray, so I decided to factor that out, modularize the ported code, and overall just spruce things up a bit. As part of that, this ports [`pg_sys::ArrayGetNItems`] to simply live inside the implementation of `RawArray::len`. This allows us to perform the calculation entirely in Rust, so there is now no more FFI overhead for creating a RawArray, and we can delete the `ARR_NELEMS` port. This also means we can simply stop caching the total element count, as we aren't saving enough math to be worth it. Now casting to RawArray from a simple reference or other raw pointer is a zero-overhead pointer cast, allowing reusing its already-defined accessors without incurring needless math or calls to Postgres. [`pg_sys::ArrayGetNItems`]: https://github.com/postgres/postgres/blob/6979ea2638a51c40acf6d04b816550b2c35b3e55/src/backend/utils/adt/arrayutils.c#L46-L102
- Loading branch information
1 parent
f3d83d2
commit 3e530b6
Showing
2 changed files
with
165 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.