LCOV - code coverage report
Current view: top level - pebble/sstable - unsafe.go (source / functions) Hit Total Coverage
Test: 2024-05-26 08:15Z 542915b2 - meta test only.lcov Lines: 8 21 38.1 %
Date: 2024-05-26 08:17:34 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2018 The LevelDB-Go and Pebble Authors. All rights reserved. Use
       2             : // of this source code is governed by a BSD-style license that can be found in
       3             : // the LICENSE file.
       4             : 
       5             : package sstable
       6             : 
       7             : import (
       8             :         "unsafe"
       9             : 
      10             :         "github.com/cockroachdb/pebble/internal/manual"
      11             : )
      12             : 
      13           1 : func getBytes(ptr unsafe.Pointer, length int) []byte {
      14           1 :         return (*[manual.MaxArrayLen]byte)(ptr)[:length:length]
      15           1 : }
      16             : 
      17           1 : func decodeVarint(ptr unsafe.Pointer) (uint32, unsafe.Pointer) {
      18           1 :         if a := *((*uint8)(ptr)); a < 128 {
      19           1 :                 return uint32(a),
      20           1 :                         unsafe.Pointer(uintptr(ptr) + 1)
      21           1 :         } else if a, b := a&0x7f, *((*uint8)(unsafe.Pointer(uintptr(ptr) + 1))); b < 128 {
      22           0 :                 return uint32(b)<<7 | uint32(a),
      23           0 :                         unsafe.Pointer(uintptr(ptr) + 2)
      24           0 :         } else if b, c := b&0x7f, *((*uint8)(unsafe.Pointer(uintptr(ptr) + 2))); c < 128 {
      25           0 :                 return uint32(c)<<14 | uint32(b)<<7 | uint32(a),
      26           0 :                         unsafe.Pointer(uintptr(ptr) + 3)
      27           0 :         } else if c, d := c&0x7f, *((*uint8)(unsafe.Pointer(uintptr(ptr) + 3))); d < 128 {
      28           0 :                 return uint32(d)<<21 | uint32(c)<<14 | uint32(b)<<7 | uint32(a),
      29           0 :                         unsafe.Pointer(uintptr(ptr) + 4)
      30           0 :         } else {
      31           0 :                 d, e := d&0x7f, *((*uint8)(unsafe.Pointer(uintptr(ptr) + 4)))
      32           0 :                 return uint32(e)<<28 | uint32(d)<<21 | uint32(c)<<14 | uint32(b)<<7 | uint32(a),
      33           0 :                         unsafe.Pointer(uintptr(ptr) + 5)
      34           0 :         }
      35             : }

Generated by: LCOV version 1.14