Skip to content

Commit 5a73a4e

Browse files
author
Joshua Wise
committed
greatly improved string performance
1 parent cdd9faa commit 5a73a4e

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/binder/bind-string.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
void Binder::BindString(v8::Local<v8::String> value, int index) {
66
if (!index) {index = NextAnonIndex();}
77

8-
v8::String::Value utf16(value);
9-
int status = sqlite3_bind_text16(handle, index, *utf16, utf16.length() * sizeof (uint16_t), bind_type);
8+
v8::String::Utf8Value utf8(value);
9+
int status = sqlite3_bind_text(handle, index, *utf8, utf8.length(), bind_type);
1010

1111
SetBindingError(status);
1212
}

src/util/data.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ v8::Local<v8::Value> GetFloatJS(sqlite3_stmt* handle, int column) {
1313
return Nan::New<v8::Number>(sqlite3_column_double(handle, column));
1414
}
1515
v8::Local<v8::Value> GetTextJS(sqlite3_stmt* handle, int column) {
16-
const void* value = sqlite3_column_text16(handle, column);
17-
int byte_count = sqlite3_column_bytes16(handle, column);
18-
return v8::String::NewFromTwoByte(
16+
const unsigned char* value = sqlite3_column_text(handle, column);
17+
int byte_count = sqlite3_column_bytes(handle, column);
18+
return v8::String::NewFromUtf8(
1919
v8::Isolate::GetCurrent(),
20-
static_cast<const uint16_t*>(value),
20+
reinterpret_cast<const char*>(value),
2121
v8::NewStringType::kNormal,
22-
byte_count / sizeof (uint16_t)
22+
byte_count
2323
).ToLocalChecked();
2424
}
2525
v8::Local<v8::Value> GetBlobJS(sqlite3_stmt* handle, int column) {
@@ -50,7 +50,7 @@ v8::Local<v8::Value> GetValueJS(sqlite3_stmt* handle, int column) {
5050
v8::Local<v8::Value> GetRowJS(sqlite3_stmt* handle, int column_count) {
5151
v8::Local<v8::Object> row = Nan::New<v8::Object>();
5252
for (int i=0; i<column_count; ++i) {
53-
Nan::Set(row, NEW_INTERNAL_STRING16(sqlite3_column_name16(handle, i)), Data::GetValueJS(handle, i));
53+
Nan::Set(row, NEW_INTERNAL_STRING8(sqlite3_column_name(handle, i)), Data::GetValueJS(handle, i));
5454
}
5555
return row;
5656
}

src/util/macros.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,6 @@ inline bool IS_32BIT_INT(double num) {
233233
v8::NewStringType::kInternalized \
234234
).ToLocalChecked()
235235

236-
// Creates a new internalized string from UTF-16 data.
237-
#define NEW_INTERNAL_STRING16(string) \
238-
v8::String::NewFromTwoByte( \
239-
v8::Isolate::GetCurrent(), \
240-
static_cast<const uint16_t*>(string), \
241-
v8::NewStringType::kInternalized \
242-
).ToLocalChecked()
243-
244236
// Creates a new internalized string, but only works with Latin-1 characters.
245237
#define NEW_INTERNAL_STRING_FAST(string) \
246238
v8::String::NewFromOneByte( \

0 commit comments

Comments
 (0)