fix: use switch instead of ifs
This commit is contained in:
parent
9a7b659919
commit
53558645c3
@ -49,12 +49,14 @@ function * lazyStructReaderGenerator (decoder) {
|
|||||||
let clock = decoding.readVarUint(decoder.restDecoder)
|
let clock = decoding.readVarUint(decoder.restDecoder)
|
||||||
for (let i = 0; i < numberOfStructs; i++) {
|
for (let i = 0; i < numberOfStructs; i++) {
|
||||||
const info = decoder.readInfo()
|
const info = decoder.readInfo()
|
||||||
// @todo use switch instead of ifs
|
switch (true) {
|
||||||
if (info === 10) {
|
case (info === 10): {
|
||||||
const len = decoding.readVarUint(decoder.restDecoder)
|
const len = decoding.readVarUint(decoder.restDecoder)
|
||||||
yield new Skip(createID(client, clock), len)
|
yield new Skip(createID(client, clock), len)
|
||||||
clock += len
|
clock += len
|
||||||
} else if ((binary.BITS5 & info) !== 0) {
|
break
|
||||||
|
}
|
||||||
|
case ((binary.BITS5 & info) !== 0): {
|
||||||
const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0
|
const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0
|
||||||
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
|
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
|
||||||
// and we read the next string as parentYKey.
|
// and we read the next string as parentYKey.
|
||||||
@ -73,10 +75,14 @@ function * lazyStructReaderGenerator (decoder) {
|
|||||||
)
|
)
|
||||||
yield struct
|
yield struct
|
||||||
clock += struct.length
|
clock += struct.length
|
||||||
} else {
|
break
|
||||||
|
}
|
||||||
|
default: {
|
||||||
const len = decoder.readLen()
|
const len = decoder.readLen()
|
||||||
yield new GC(createID(client, clock), len)
|
yield new GC(createID(client, clock), len)
|
||||||
clock += len
|
clock += len
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user