Skip to content

Commit 38c728f

Browse files
1011zaozao-maxmourner
authored andcommitted
Use unary operators to make code cleaner
1 parent 3e6453e commit 38c728f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ export default class TinyQueue {
1212

1313
push(item) {
1414
this.data.push(item);
15-
this.length++;
16-
this._up(this.length - 1);
15+
this._up(this.length++);
1716
}
1817

1918
pop() {
2019
if (this.length === 0) return undefined;
2120

2221
const top = this.data[0];
2322
const bottom = this.data.pop();
24-
this.length--;
2523

26-
if (this.length > 0) {
24+
if (--this.length > 0) {
2725
this.data[0] = bottom;
2826
this._down(0);
2927
}

0 commit comments

Comments
 (0)