Skip to content

Commit

Permalink
Merge pull request #26 from alessandromrc/main-1x
Browse files Browse the repository at this point in the history
Performance Improvement when writing
  • Loading branch information
sombriks committed Mar 29, 2024
2 parents e9e8304 + 6907306 commit 5787dd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"libraries" : [
"-lgpiod"
],
"cflags": [
"-O3"
],
"lflags": [
"-flto"
]
}]
]
}
Expand Down
12 changes: 5 additions & 7 deletions src/line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ NAN_METHOD(Line::getValue) {
}

NAN_METHOD(Line::setValue) {
Line *obj = Nan::ObjectWrap::Unwrap<Line>(info.This());
if (!obj->line) {
Nan::ThrowError("::setValue() for line==NULL");
return;
Line *obj = ObjectWrap::Unwrap<Line>(info.Holder());
v8::Local<v8::Context> context = Nan::GetCurrentContext();
uint32_t value = info[0]->Uint32Value(context).FromJust();
if (gpiod_line_set_value(obj->line, value) == -1) {
return Nan::ThrowError("setValue() failed.");
}
unsigned int value = Nan::To<unsigned int>(info[0]).FromJust();
if (-1 == gpiod_line_set_value(obj->getNativeLine(), value))
Nan::ThrowError("::setValue() failed");
}

NAN_METHOD(Line::requestInputMode) {
Expand Down

0 comments on commit 5787dd0

Please sign in to comment.