Skip to content

Commit 3d1ff26

Browse files
committed
src: use string view instead of local
This reverts commit 1340a81744b5a934b4ea0423bc01d424fa152127.
1 parent 25271b2 commit 3d1ff26

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/node_sqlite.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "util-inl.h"
1212

1313
#include <cinttypes>
14+
#include <string_view>
1415

1516
namespace node {
1617
namespace sqlite {
@@ -78,12 +79,11 @@ inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, sqlite3* db) {
7879

7980
DatabaseSync::DatabaseSync(Environment* env,
8081
Local<Object> object,
81-
Local<String> location,
82+
std::string_view location,
8283
bool open)
8384
: BaseObject(env, object) {
8485
MakeWeak();
85-
Utf8Value utf8_location(env->isolate(), location);
86-
location_ = utf8_location.ToString();
86+
location_ = std::string(location);
8787
connection_ = nullptr;
8888

8989
if (open) {
@@ -178,7 +178,10 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
178178
}
179179
}
180180

181-
new DatabaseSync(env, args.This(), args[0].As<String>(), open);
181+
BufferValue location(env->isolate(), args[0]);
182+
CHECK_NOT_NULL(*location);
183+
ToNamespacedPath(env, &location);
184+
new DatabaseSync(env, args.This(), location.ToStringView(), open);
182185
}
183186

184187
void DatabaseSync::Open(const FunctionCallbackInfo<Value>& args) {

src/node_sqlite.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "util.h"
1010

1111
#include <map>
12+
#include <string_view>
1213
#include <unordered_set>
1314

1415
namespace node {
@@ -20,7 +21,7 @@ class DatabaseSync : public BaseObject {
2021
public:
2122
DatabaseSync(Environment* env,
2223
v8::Local<v8::Object> object,
23-
v8::Local<v8::String> location,
24+
std::string_view location,
2425
bool open);
2526
void MemoryInfo(MemoryTracker* tracker) const override;
2627
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);

0 commit comments

Comments
 (0)