LCOV - code coverage report
Current view: top level - pebble/internal/intern - intern.go (source / functions) Hit Total Coverage
Test: 2023-12-03 08:16Z 51fca96d - tests only.lcov Lines: 14 14 100.0 %
Date: 2023-12-03 08:16:35 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2020 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 intern
       6             : 
       7             : import "sync"
       8             : 
       9             : var pool = sync.Pool{
      10           1 :         New: func() interface{} {
      11           1 :                 return make(map[string]string)
      12           1 :         },
      13             : }
      14             : 
      15             : // Bytes returns b converted to a string, interned.
      16           1 : func Bytes(b []byte) string {
      17           1 :         m := pool.Get().(map[string]string)
      18           1 :         c, ok := m[string(b)]
      19           1 :         if ok {
      20           1 :                 pool.Put(m)
      21           1 :                 return c
      22           1 :         }
      23           1 :         s := string(b)
      24           1 :         m[s] = s
      25           1 :         pool.Put(m)
      26           1 :         return s
      27             : }

Generated by: LCOV version 1.14