Skip to content

Commit ca4cafe

Browse files
committed
Length check in others
1 parent 511f7cb commit ca4cafe

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

examples.htm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
550550
document.getElementById('plaindraw').innerHTML = '';
551551
document.getElementById('plaindraw').style['background-color'] = '';
552552

553-
if (durl.length > 0) {
553+
if (durl) {
554554
return drawUrl(durl + (opt ? `&opt=${opt}` : '') + extra_opts);
555555
} else if (jsonname) {
556556
return httpRequest(jsonname, 'object')
@@ -699,26 +699,26 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
699699

700700
createRootColors(); // ensure default colors
701701

702-
if (url.length > 0) {
702+
if (url) {
703703
if (no_interactive)
704704
url += '&interactive=0';
705705

706706
testfile = testobj = null;
707707
// if (keyid == 'TGeo') return runBigTest(0); // ignore TGeo URLs - too complex
708708

709709
drawUrl(url).then(TestContinue, TestFailure);
710-
} else if (jsonname.length > 0) {
710+
} else if (jsonname) {
711711
testfile = testobj = null;
712712
httpRequest(jsonname, 'object').then(obj => {
713713
testobj = obj;
714714
return drawEntry(entry, obj, opt).then(TestContinue, TestFailure);
715715
});
716-
} else if (filename.length > 0) {
716+
} else if (filename) {
717717
openFile(filename)
718718
.then(file => { testfile = file; return testfile.readObject(itemname); })
719719
.then(obj => { testobj = obj; return drawEntry(entry, obj, opt); })
720720
.then(TestContinue, TestFailure);
721-
} else if (itemname.length > 0) {
721+
} else if (itemname) {
722722
testfile.readObject(itemname)
723723
.then(obj => { testobj = obj; return drawEntry(entry, obj, opt); })
724724
.then(TestContinue, TestFailure);

modules/gui/menu.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class JSRootMenu {
155155
if (without_sub)
156156
name = top_name + ' ' + name;
157157

158-
if (group.length > 0) {
158+
if (group.length) {
159159
this.sub(name, opts[i], call_back);
160160
group.forEach(sub => {
161161
this.add(sub, sub, call_back);

modules/tree.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class ArrayIterator {
198198
continue;
199199
}
200200

201-
if ((typ === 'array') && ((obj.length > 0) || (this.select[cnt + 1] === '$size$'))) {
201+
if ((typ === 'array') && (obj.length || (this.select[cnt + 1] === '$size$'))) {
202202
this.arr[++cnt] = obj;
203203
switch (this.select[cnt]) {
204204
case undefined: this.indx[cnt] = 0; break;
@@ -2348,7 +2348,7 @@ async function treeProcess(tree, selector, args) {
23482348

23492349
const branch = bitems[n].branch;
23502350

2351-
if (places.length === 0)
2351+
if (!places.length)
23522352
filename = branch.fFileName;
23532353
else if (filename !== branch.fFileName)
23542354
continue;
@@ -2358,7 +2358,7 @@ async function treeProcess(tree, selector, args) {
23582358
places.push(branch.fBasketSeek[bitems[n].basket], branch.fBasketBytes[bitems[n].basket]);
23592359
}
23602360

2361-
return places.length > 0 ? { places, filename } : null;
2361+
return places.length ? { places, filename } : null;
23622362
}
23632363

23642364
function readProgress(value) {
@@ -2633,7 +2633,7 @@ async function treeProcess(tree, selector, args) {
26332633
if (handle.process_entries !== undefined) {
26342634
elem.selected_baskets.shift();
26352635
// -1 means that basket is not yet found for following entries
2636-
elem.curr_basket = (elem.selected_baskets.length > 0) ? elem.selected_baskets[0] : -1;
2636+
elem.curr_basket = elem.selected_baskets.length ? elem.selected_baskets[0] : -1;
26372637
}
26382638
}
26392639

@@ -2918,7 +2918,7 @@ function treeHierarchy(tree_node, obj) {
29182918
const object_class = getBranchObjectClass(bobj, bobj.$tree, true),
29192919
methods = object_class ? getMethods(object_class) : null;
29202920

2921-
if (methods && (bobj.fBranches.arr.length > 0)) {
2921+
if (methods && bobj.fBranches.arr.length) {
29222922
for (const key in methods) {
29232923
if (!isFunc(methods[key])) continue;
29242924
const s = methods[key].toString();
@@ -2963,8 +2963,7 @@ function treeHierarchy(tree_node, obj) {
29632963
tree_node._childs = [];
29642964
tree_node._tree = obj; // set reference, will be used later by TTree::Draw
29652965

2966-
for (let i = 0; i < obj.fBranches?.arr.length; ++i)
2967-
createBranchItem(tree_node, obj.fBranches.arr[i], obj);
2966+
obj.fBranches?.arr.forEach(branch => createBranchItem(tree_node, branch, obj));
29682967

29692968
return true;
29702969
}

modules/webwindow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class WebWindowHandle {
388388
processQueue() {
389389
if (this._loop_msgqueue || !this.msgqueue) return;
390390
this._loop_msgqueue = true;
391-
while ((this.msgqueue.length > 0) && this.msgqueue[0].ready) {
391+
while (this.msgqueue.length && this.msgqueue[0].ready) {
392392
const front = this.msgqueue.shift();
393393
this.invokeReceiver(false, 'onWebsocketMsg', front.msg, front.len);
394394
}

scripts/JSRoot.core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ exports.decodeUrl = function(url) {
239239
if (p1 < 0) return res;
240240
url = decodeURI(url.slice(p1+1));
241241

242-
while (url.length > 0) {
242+
while (url) {
243243
// try to correctly handle quotes in the URL
244244
let pos = 0, nq = 0, eq = -1, firstq = -1;
245245
while ((pos < url.length) && ((nq !== 0) || ((url[pos] !== '&') && (url[pos] !== '#')))) {

0 commit comments

Comments
 (0)