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)
 | 
			
		||||
    for (let i = 0; i < numberOfStructs; i++) {
 | 
			
		||||
      const info = decoder.readInfo()
 | 
			
		||||
      // @todo use switch instead of ifs
 | 
			
		||||
      if (info === 10) {
 | 
			
		||||
      switch (true) {
 | 
			
		||||
        case (info === 10): {
 | 
			
		||||
          const len = decoding.readVarUint(decoder.restDecoder)
 | 
			
		||||
          yield new Skip(createID(client, clock), len)
 | 
			
		||||
          clock += len
 | 
			
		||||
      } else if ((binary.BITS5 & info) !== 0) {
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
        case ((binary.BITS5 & info) !== 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`
 | 
			
		||||
          // and we read the next string as parentYKey.
 | 
			
		||||
@ -73,10 +75,14 @@ function * lazyStructReaderGenerator (decoder) {
 | 
			
		||||
          )
 | 
			
		||||
          yield struct
 | 
			
		||||
          clock += struct.length
 | 
			
		||||
      } else {
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
        default: {
 | 
			
		||||
          const len = decoder.readLen()
 | 
			
		||||
          yield new GC(createID(client, clock), len)
 | 
			
		||||
          clock += len
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user