Skip to content

Commit

Permalink
src: use string view instead of local
Browse files Browse the repository at this point in the history
This reverts commit 1340a81744b5a934b4ea0423bc01d424fa152127.
  • Loading branch information
JonasBa committed Aug 22, 2024
1 parent cb81845 commit 5f2f4a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "util-inl.h"

#include <cinttypes>
#include <string_view>

namespace node {
namespace sqlite {
Expand Down Expand Up @@ -78,12 +79,11 @@ inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, sqlite3* db) {

DatabaseSync::DatabaseSync(Environment* env,
Local<Object> object,
Local<String> location,
std::string_view location,
bool open)
: BaseObject(env, object) {
MakeWeak();
Utf8Value utf8_location(env->isolate(), location);
location_ = utf8_location.ToString();
location_ = std::string(location);
connection_ = nullptr;

if (open) {
Expand Down Expand Up @@ -178,7 +178,10 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
}
}

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

void DatabaseSync::Open(const FunctionCallbackInfo<Value>& args) {
Expand Down
3 changes: 2 additions & 1 deletion src/node_sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "util.h"

#include <map>
#include <string_view>
#include <unordered_set>

namespace node {
Expand All @@ -20,7 +21,7 @@ class DatabaseSync : public BaseObject {
public:
DatabaseSync(Environment* env,
v8::Local<v8::Object> object,
v8::Local<v8::String> location,
std::string_view location,
bool open);
void MemoryInfo(MemoryTracker* tracker) const override;
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
Expand Down

0 comments on commit 5f2f4a1

Please sign in to comment.