Repository navigation
refactor: share SQLite value binding and buffer snapshots #533
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #pragma once | ||
|
|
||
| #include "../SQLiteTypes.hpp" | ||
|
|
||
| namespace margelo::nitro::nitrosqlite { | ||
|
|
||
| // Copy any JS-backed ArrayBuffers on the JS thread so they can be safely | ||
| // accessed from the connection's background worker. | ||
| inline std::optional<SQLiteQueryParams> copyArrayBufferParamsForBackground(const std::optional<SQLiteQueryParams>& params) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apex: Skipping this call still compiles, and so does capturing |
||
| if (!params) { | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| SQLiteQueryParams copiedParams; | ||
| copiedParams.reserve(params->size()); | ||
|
|
||
| for (const auto& value : *params) { | ||
| if (value && std::holds_alternative<ArrayBuffer>(*value)) { | ||
| const auto& buffer = std::get<ArrayBuffer>(*value); | ||
| const auto copiedBuffer = ArrayBuffer::copy(buffer); | ||
| copiedParams.push_back(copiedBuffer); | ||
| } else { | ||
| copiedParams.push_back(value); | ||
| } | ||
| } | ||
|
|
||
| return copiedParams; | ||
| } | ||
|
|
||
| } // namespace margelo::nitro::nitrosqlite | ||
Uh oh!
There was an error while loading. Please reload this page.