Skip to content

Commit 86c1ff7

Browse files
committed
fix: getChildren return directly without extra local declaration
1 parent 40cfc66 commit 86c1ff7

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/tree.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66

77
/** Get the children of a jsTree (Napi::Object) */
88
inline std::optional<Napi::Array> getChildren(const Napi::Object &&jsTree, const string &&childrenKey) {
9-
Napi::Array childrenArray;
10-
119
// determine if it has children
12-
auto hasChildren = false;
1310
if (jsTree.HasOwnProperty(childrenKey)) {
1411
const auto childrenRaw = jsTree.Get(move_const(childrenKey));
1512
if (childrenRaw.IsArray()) {
16-
childrenArray = childrenRaw.As<Napi::Array>();
13+
const auto childrenArray = childrenRaw.As<Napi::Array>();
1714
if (childrenArray.Length() != 0) {
18-
hasChildren = true;
15+
return childrenArray;
1916
}
2017
}
2118
}
22-
if (hasChildren) {
23-
return childrenArray;
24-
}
2519
return {};
2620
}
2721

0 commit comments

Comments
 (0)