Skip to content

Commit 62db9a0

Browse files
jasnelltargos
authored andcommitted
src: minor http2 refactorings
* Simplify Http2Priority struct * BooleanValue => IsTrue/IsFalse Signed-off-by: James M Snell <[email protected]> PR-URL: #32551 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 8f766e8 commit 62db9a0

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/node_http2.cc

+7-10
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ Http2Priority::Http2Priority(Environment* env,
347347
Local<Context> context = env->context();
348348
int32_t parent_ = parent->Int32Value(context).ToChecked();
349349
int32_t weight_ = weight->Int32Value(context).ToChecked();
350-
bool exclusive_ = exclusive->BooleanValue(env->isolate());
350+
bool exclusive_ = exclusive->IsTrue();
351351
Debug(env, DebugCategory::HTTP2STREAM,
352352
"Http2Priority: parent: %d, weight: %d, exclusive: %s\n",
353353
parent_, weight_, exclusive_ ? "yes" : "no");
354-
nghttp2_priority_spec_init(&spec, parent_, weight_, exclusive_ ? 1 : 0);
354+
nghttp2_priority_spec_init(this, parent_, weight_, exclusive_ ? 1 : 0);
355355
}
356356

357357

@@ -995,8 +995,7 @@ int Http2Session::OnStreamClose(nghttp2_session* handle,
995995
MaybeLocal<Value> answer =
996996
stream->MakeCallback(env->http2session_on_stream_close_function(),
997997
1, &arg);
998-
if (answer.IsEmpty() ||
999-
!(answer.ToLocalChecked()->BooleanValue(env->isolate()))) {
998+
if (answer.IsEmpty() || answer.ToLocalChecked()->IsFalse()) {
1000999
// Skip to destroy
10011000
stream->Destroy();
10021001
}
@@ -2443,9 +2442,7 @@ void Http2Session::Destroy(const FunctionCallbackInfo<Value>& args) {
24432442
Local<Context> context = env->context();
24442443

24452444
uint32_t code = args[0]->Uint32Value(context).ToChecked();
2446-
bool socketDestroyed = args[1]->BooleanValue(env->isolate());
2447-
2448-
session->Close(code, socketDestroyed);
2445+
session->Close(code, args[1]->IsTrue());
24492446
}
24502447

24512448
// Submits a new request on the Http2Session and returns either an error code
@@ -2464,7 +2461,7 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
24642461
int32_t ret = 0;
24652462
Http2Stream* stream =
24662463
session->Http2Session::SubmitRequest(
2467-
*priority,
2464+
&priority,
24682465
Http2Headers(env, headers),
24692466
&ret,
24702467
static_cast<int>(options));
@@ -2637,9 +2634,9 @@ void Http2Stream::Priority(const FunctionCallbackInfo<Value>& args) {
26372634
ASSIGN_OR_RETURN_UNWRAP(&stream, args.Holder());
26382635

26392636
Http2Priority priority(env, args[0], args[1], args[2]);
2640-
bool silent = args[3]->BooleanValue(env->isolate());
2637+
bool silent = args[3]->IsTrue();
26412638

2642-
CHECK_EQ(stream->SubmitPriority(*priority, silent), 0);
2639+
CHECK_EQ(stream->SubmitPriority(&priority, silent), 0);
26432640
Debug(stream, "priority submitted");
26442641
}
26452642

src/node_http2.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,11 @@ class Http2Options {
246246
size_t max_outstanding_settings_ = kDefaultMaxSettings;
247247
};
248248

249-
class Http2Priority {
250-
public:
249+
struct Http2Priority : public nghttp2_priority_spec {
251250
Http2Priority(Environment* env,
252251
v8::Local<v8::Value> parent,
253252
v8::Local<v8::Value> weight,
254253
v8::Local<v8::Value> exclusive);
255-
256-
nghttp2_priority_spec* operator*() {
257-
return &spec;
258-
}
259-
private:
260-
nghttp2_priority_spec spec;
261254
};
262255

263256
class Http2StreamListener : public StreamListener {

0 commit comments

Comments
 (0)