Skip to content

Commit

Permalink
Update addon.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed May 12, 2024
1 parent 959107c commit 0cbdf5e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ using namespace v8;

#include "v8-fast-api-calls.h" // go with nodejs 20 for now

Isolate *isolate;

void SlowByteLengthUtf8(const FunctionCallbackInfo<Value>& args) {
isolate = args.GetIsolate();

printf("calling slow\n");
}

Expand All @@ -52,6 +56,11 @@ void FastByteLengthUtf8(Local<Value> receiver, const v8::FastOneByteString& sour

void FastByteLengthUtf8(Local<Value> receiver, Local<Value> val) {
//fwrite(source.data, 1, source.length, stdout);

static char buf[1024 * 16];
int len = Local<String>::Cast(val)->WriteUtf8(isolate, buf);

fwrite(buf, 1, len, stdout);
}

v8::CFunction fast_byte_length_utf8(v8::CFunction::Make(FastByteLengthUtf8));
Expand Down

0 comments on commit 0cbdf5e

Please sign in to comment.