Skip to content

Commit

Permalink
Constructing JS strings from C strings is more expensive than passing…
Browse files Browse the repository at this point in the history
… std::strings
  • Loading branch information
marcomagdy committed Nov 29, 2023
1 parent 4d0017e commit 5afa0e4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/rapid-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RuntimeApiNextPromiseWorker : public Napi::AsyncWorker {

void OnOK() override {
Napi::Env env = Env();
auto response_data = Napi::String::New(env, response.payload.c_str());
auto response_data = Napi::String::New(env, response.payload);

// TODO: The current javascript code (InvokeContext.js) to handle the header values itself.
// These type conversions might be replaced by returning the final context object.
Expand All @@ -64,22 +64,22 @@ class RuntimeApiNextPromiseWorker : public Napi::AsyncWorker {
));
headers.Set(
Napi::String::New(env, "lambda-runtime-aws-request-id"),
Napi::String::New(env, response.request_id.c_str()));
Napi::String::New(env, response.request_id));
headers.Set(
Napi::String::New(env, "lambda-runtime-trace-id"),
Napi::String::New(env, response.xray_trace_id.c_str()));
Napi::String::New(env, response.xray_trace_id));
headers.Set(
Napi::String::New(env, "lambda-runtime-invoked-function-arn"),
Napi::String::New(env, response.function_arn.c_str()));
Napi::String::New(env, response.function_arn));
if (!response.client_context.empty()) {
headers.Set(
Napi::String::New(env, "lambda-runtime-client-context"),
Napi::String::New(env, response.client_context.c_str()));
Napi::String::New(env, response.client_context));
}
if (!response.cognito_identity.empty()) {
headers.Set(
Napi::String::New(env, "lambda-runtime-cognito-identity"),
Napi::String::New(env, response.cognito_identity.c_str()));
Napi::String::New(env, response.cognito_identity));
}

auto ret = Napi::Object::New(env);
Expand Down

0 comments on commit 5afa0e4

Please sign in to comment.