Skip to content

Commit 848b407

Browse files
committed
fixup: suggestion (manual check)
1 parent ae3ca8c commit 848b407

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/node_sqlite.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ void StatementSync::Columns(const FunctionCallbackInfo<Value>& args) {
22732273
NullableSQLiteStringToValue(
22742274
isolate, sqlite3_column_decltype(stmt->statement_, i)),
22752275
};
2276+
if (IsAnyEntryEmpty(values)) return;
22762277

22772278
cols.emplace_back(
22782279
sqlite_column_template->NewInstance(env->context(), values));

src/node_url_pattern.cc

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -440,37 +440,18 @@ MaybeLocal<Value> URLPattern::URLPatternResult::ToJSValue(
440440
return {};
441441
}
442442

443-
Local<Object> results[8];
444-
if (!URLPatternComponentResult::ToJSObject(env, result.protocol)
445-
.ToLocal(&results[0]) ||
446-
!URLPatternComponentResult::ToJSObject(env, result.username)
447-
.ToLocal(&results[1]) ||
448-
!URLPatternComponentResult::ToJSObject(env, result.password)
449-
.ToLocal(&results[2]) ||
450-
!URLPatternComponentResult::ToJSObject(env, result.hostname)
451-
.ToLocal(&results[3]) ||
452-
!URLPatternComponentResult::ToJSObject(env, result.port)
453-
.ToLocal(&results[4]) ||
454-
!URLPatternComponentResult::ToJSObject(env, result.pathname)
455-
.ToLocal(&results[5]) ||
456-
!URLPatternComponentResult::ToJSObject(env, result.search)
457-
.ToLocal(&results[6]) ||
458-
!URLPatternComponentResult::ToJSObject(env, result.hash)
459-
.ToLocal(&results[7])) {
460-
return {};
461-
}
462-
463443
MaybeLocal<Value> vals[] = {
464444
inputs,
465-
results[0], /** protocol */
466-
results[1], /** username */
467-
results[2], /** password */
468-
results[3], /** hostname */
469-
results[4], /** port */
470-
results[5], /** pathname */
471-
results[6], /** search */
472-
results[7], /** hash */
445+
URLPatternComponentResult::ToJSObject(env, result.protocol),
446+
URLPatternComponentResult::ToJSObject(env, result.username),
447+
URLPatternComponentResult::ToJSObject(env, result.password),
448+
URLPatternComponentResult::ToJSObject(env, result.hostname),
449+
URLPatternComponentResult::ToJSObject(env, result.port),
450+
URLPatternComponentResult::ToJSObject(env, result.pathname),
451+
URLPatternComponentResult::ToJSObject(env, result.search),
452+
URLPatternComponentResult::ToJSObject(env, result.hash),
473453
};
454+
if (IsAnyEntryEmpty(vals)) return {};
474455
return tmpl->NewInstance(env->context(), vals);
475456
}
476457

src/node_util.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
305305
Integer::NewFromUnsigned(isolate, stack_frame->GetColumn()),
306306
};
307307

308+
if (IsAnyEntryEmpty(values)) return;
308309
callsite_objects.push_back(
309310
callsite_template->NewInstance(env->context(), values));
310311
}

src/util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,14 @@ class JSONOutputStream final : public v8::OutputStream {
10331033
std::ostringstream out_stream_;
10341034
};
10351035

1036+
template <typename T>
1037+
inline bool IsAnyEntryEmpty(const T& t) {
1038+
for (const auto& e : t) {
1039+
if (e.IsEmpty()) return true;
1040+
}
1041+
return false;
1042+
}
1043+
10361044
#ifdef _WIN32
10371045
// Returns true if OS==Windows and filename ends in .bat or .cmd,
10381046
// case insensitive.

0 commit comments

Comments
 (0)