@op-engineering/op-sqlite 9.0.0 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![benchmark](benchmark.png)
1
+ ![benchmark](benchmark.jpg)
2
2
 
3
3
  Created by [@ospfranco](https://twitter.com/ospfranco). **Please consider sponsoring!**.
4
4
 
@@ -379,7 +379,7 @@ void DBHostObject::create_jsi_functions() {
379
379
  auto resolve = std::make_shared<jsi::Value>(rt, args[0]);
380
380
  auto reject = std::make_shared<jsi::Value>(rt, args[1]);
381
381
 
382
- auto task = [&rt, this, query, params = std::move(params), resolve,
382
+ auto task = [&rt, this, query = std::move(query), params = std::move(params), resolve,
383
383
  reject, invoker = this->jsCallInvoker]() {
384
384
  try {
385
385
 
package/cpp/bridge.cpp CHANGED
@@ -315,7 +315,7 @@ BridgeResult opsqlite_execute_prepared_statement(
315
315
  }
316
316
 
317
317
  if (results != nullptr) {
318
- results->push_back(row);
318
+ results->emplace_back(row);
319
319
  }
320
320
 
321
321
  break;
@@ -335,7 +335,7 @@ BridgeResult opsqlite_execute_prepared_statement(
335
335
  metadata.fields.emplace_back("type",
336
336
  type == nullptr ? "UNKNOWN" : type);
337
337
 
338
- metadatas->push_back(metadata);
338
+ metadatas->emplace_back(metadata);
339
339
  i++;
340
340
  }
341
341
  }
@@ -401,6 +401,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
401
401
  std::string column_name, column_declared_type;
402
402
  std::vector<std::string> column_names;
403
403
  std::vector<std::vector<JSVariant>> rows;
404
+ rows.reserve(20);
404
405
  std::vector<JSVariant> row;
405
406
 
406
407
  do {
@@ -429,6 +430,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
429
430
  }
430
431
 
431
432
  column_count = sqlite3_column_count(statement);
433
+ column_names.reserve(column_count);
432
434
  bool is_consuming_rows = true;
433
435
  double double_value;
434
436
  const char *string_value;
@@ -436,7 +438,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
436
438
  // Do a first pass to get the column names
437
439
  for (int i = 0; i < column_count; i++) {
438
440
  column_name = sqlite3_column_name(statement, i);
439
- column_names.push_back(column_name);
441
+ column_names.emplace_back(column_name);
440
442
  }
441
443
 
442
444
  while (is_consuming_rows) {
@@ -446,7 +448,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
446
448
  case SQLITE_ROW:
447
449
  current_column = 0;
448
450
  row = std::vector<JSVariant>();
449
- column_count = sqlite3_column_count(statement);
451
+ row.reserve(column_count);
450
452
 
451
453
  while (current_column < column_count) {
452
454
  column_type = sqlite3_column_type(statement, current_column);
@@ -464,9 +466,9 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
464
466
  case SQLITE_TEXT: {
465
467
  string_value = reinterpret_cast<const char *>(
466
468
  sqlite3_column_text(statement, current_column));
467
- int byteLen = sqlite3_column_bytes(statement, current_column);
469
+ int len = sqlite3_column_bytes(statement, current_column);
468
470
  // Specify length too; in case string contains NULL in the middle
469
- row.emplace_back(std::string(string_value, byteLen));
471
+ row.emplace_back(std::string(string_value, len));
470
472
  break;
471
473
  }
472
474
 
@@ -491,7 +493,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
491
493
  current_column++;
492
494
  }
493
495
 
494
- rows.push_back(row);
496
+ rows.emplace_back(std::move(row));
495
497
  break;
496
498
 
497
499
  case SQLITE_DONE:
package/cpp/utils.cpp CHANGED
@@ -13,7 +13,7 @@ namespace opsqlite {
13
13
 
14
14
  namespace jsi = facebook::jsi;
15
15
 
16
- jsi::Value toJSI(jsi::Runtime &rt, JSVariant value) {
16
+ jsi::Value toJSI(jsi::Runtime &rt, const JSVariant &value) {
17
17
  if (std::holds_alternative<bool>(value)) {
18
18
  return std::get<bool>(value);
19
19
  } else if (std::holds_alternative<int>(value)) {
@@ -158,7 +158,7 @@ std::vector<JSVariant> to_variant_vec(jsi::Runtime &rt, jsi::Value const &xs) {
158
158
  return res;
159
159
  }
160
160
 
161
- jsi::Value create_js_rows(jsi::Runtime &rt, BridgeResult status) {
161
+ jsi::Value create_js_rows(jsi::Runtime &rt, const BridgeResult &status) {
162
162
  if (status.type == SQLiteError) {
163
163
  throw std::invalid_argument(status.message);
164
164
  }
@@ -181,10 +181,10 @@ jsi::Value create_js_rows(jsi::Runtime &rt, BridgeResult status) {
181
181
  auto value = toJSI(rt, native_row[j]);
182
182
  row.setValueAtIndex(rt, j, value);
183
183
  }
184
- rows.setValueAtIndex(rt, i, std::move(row));
184
+ rows.setValueAtIndex(rt, i, row);
185
185
  }
186
186
  }
187
- res.setProperty(rt, "rawRows", std::move(rows));
187
+ res.setProperty(rt, "rawRows", rows);
188
188
 
189
189
  size_t column_count = status.column_names.size();
190
190
  auto column_array = jsi::Array(rt, column_count);
package/cpp/utils.h CHANGED
@@ -15,7 +15,7 @@ namespace opsqlite {
15
15
 
16
16
  namespace jsi = facebook::jsi;
17
17
 
18
- jsi::Value toJSI(jsi::Runtime &rt, JSVariant value);
18
+ jsi::Value toJSI(jsi::Runtime &rt, const JSVariant &value);
19
19
  JSVariant toVariant(jsi::Runtime &rt, jsi::Value const &value);
20
20
  std::vector<std::string> to_string_vec(jsi::Runtime &rt, jsi::Value const &xs);
21
21
  std::vector<JSVariant> to_variant_vec(jsi::Runtime &rt, jsi::Value const &xs);
@@ -23,7 +23,7 @@ std::vector<int> to_int_vec(jsi::Runtime &rt, jsi::Value const &xs);
23
23
  jsi::Value createResult(jsi::Runtime &rt, BridgeResult status,
24
24
  std::vector<DumbHostObject> *results,
25
25
  std::shared_ptr<std::vector<SmartHostObject>> metadata);
26
- jsi::Value create_js_rows(jsi::Runtime &rt, BridgeResult status);
26
+ jsi::Value create_js_rows(jsi::Runtime &rt, const BridgeResult &status);
27
27
  jsi::Value
28
28
  create_raw_result(jsi::Runtime &rt, BridgeResult status,
29
29
  const std::vector<std::vector<JSVariant>> *results);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "9.0.0",
3
+ "version": "9.1.1",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",