Skip to content

Commit 6606414

Browse files
committed
review fixed
1 parent 4a7f33b commit 6606414

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/node_sqlite.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,8 @@ Intercepted DatabaseSyncLimits::LimitsQuery(
819819
}
820820

821821
// Property exists and is writable
822-
info.GetReturnValue().Set(Integer::New(isolate, v8::PropertyAttribute::DontDelete));
822+
info.GetReturnValue().Set(
823+
Integer::New(isolate, v8::PropertyAttribute::DontDelete));
823824
return Intercepted::kYes;
824825
}
825826

@@ -950,12 +951,8 @@ bool DatabaseSync::Open() {
950951
sqlite3_busy_timeout(connection_, open_config_.get_timeout());
951952

952953
// Apply initial limits
953-
const auto& limits = open_config_.initial_limits();
954-
for (size_t limit_id = 0; limit_id < limits.size(); ++limit_id) {
955-
if (limits[limit_id].has_value()) {
956-
sqlite3_limit(
957-
connection_, static_cast<int>(limit_id), limits[limit_id].value());
958-
}
954+
for (const auto& [limit_id, limit_value] : open_config_.initial_limits()) {
955+
sqlite3_limit(connection_, limit_id, limit_value);
959956
}
960957

961958
if (allow_load_extension_) {

src/node_sqlite.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ class DatabaseOpenConfiguration {
9393
inline bool get_enable_defensive() const { return defensive_; }
9494

9595
inline void set_initial_limit(int limit_id, int value) {
96-
initial_limits_.at(limit_id) = value;
96+
initial_limits_[limit_id] = value;
9797
}
9898

99-
inline const std::array<std::optional<int>, kLimitMapping.size()>&
100-
initial_limits() const {
99+
inline const std::map<int, int>& initial_limits() const {
101100
return initial_limits_;
102101
}
103102

@@ -112,7 +111,7 @@ class DatabaseOpenConfiguration {
112111
bool allow_bare_named_params_ = true;
113112
bool allow_unknown_named_params_ = false;
114113
bool defensive_ = true;
115-
std::array<std::optional<int>, kLimitMapping.size()> initial_limits_;
114+
std::map<int, int> initial_limits_;
116115
};
117116

118117
class DatabaseSync;

0 commit comments

Comments
 (0)