Skip to content

Commit 5b2876e

Browse files
committed
src: inline reset
1 parent a430473 commit 5b2876e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/node_sqlite.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,11 @@ inline bool StatementSync::IsFinalized() {
21532153
return statement_ == nullptr;
21542154
}
21552155

2156+
inline int StatementSync::ResetStatement() {
2157+
reset_generation_++;
2158+
return sqlite3_reset(statement_);
2159+
}
2160+
21562161
bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& args) {
21572162
int r = sqlite3_clear_bindings(statement_);
21582163
CHECK_ERROR_OR_THROW(env()->isolate(), db_.get(), r, SQLITE_OK, false);
@@ -2544,8 +2549,7 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
25442549
THROW_AND_RETURN_ON_BAD_STATE(
25452550
env, stmt->IsFinalized(), "statement has been finalized");
25462551
Isolate* isolate = env->isolate();
2547-
stmt->reset_generation_++;
2548-
int r = sqlite3_reset(stmt->statement_);
2552+
int r = stmt->ResetStatement();
25492553
CHECK_ERROR_OR_THROW(isolate, stmt->db_.get(), r, SQLITE_OK, void());
25502554

25512555
if (!stmt->BindParams(args)) {
@@ -2571,8 +2575,7 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
25712575
Environment* env = Environment::GetCurrent(args);
25722576
THROW_AND_RETURN_ON_BAD_STATE(
25732577
env, stmt->IsFinalized(), "statement has been finalized");
2574-
stmt->reset_generation_++;
2575-
int r = sqlite3_reset(stmt->statement_);
2578+
int r = stmt->ResetStatement();
25762579
CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
25772580

25782581
if (!stmt->BindParams(args)) {
@@ -2595,8 +2598,7 @@ void StatementSync::Get(const FunctionCallbackInfo<Value>& args) {
25952598
Environment* env = Environment::GetCurrent(args);
25962599
THROW_AND_RETURN_ON_BAD_STATE(
25972600
env, stmt->IsFinalized(), "statement has been finalized");
2598-
stmt->reset_generation_++;
2599-
int r = sqlite3_reset(stmt->statement_);
2601+
int r = stmt->ResetStatement();
26002602
CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
26012603

26022604
if (!stmt->BindParams(args)) {
@@ -2620,8 +2622,7 @@ void StatementSync::Run(const FunctionCallbackInfo<Value>& args) {
26202622
Environment* env = Environment::GetCurrent(args);
26212623
THROW_AND_RETURN_ON_BAD_STATE(
26222624
env, stmt->IsFinalized(), "statement has been finalized");
2623-
stmt->reset_generation_++;
2624-
int r = sqlite3_reset(stmt->statement_);
2625+
int r = stmt->ResetStatement();
26252626
CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
26262627

26272628
if (!stmt->BindParams(args)) {

src/node_sqlite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class StatementSync : public BaseObject {
244244
bool allow_unknown_named_params_;
245245
uint64_t reset_generation_ = 0;
246246
std::optional<std::map<std::string, std::string>> bare_named_params_;
247+
inline int ResetStatement();
247248
bool BindParams(const v8::FunctionCallbackInfo<v8::Value>& args);
248249
bool BindValue(const v8::Local<v8::Value>& value, const int index);
249250

0 commit comments

Comments
 (0)