LCOV - code coverage report
Current view: top level - src/leveldb/table - iterator.cc (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 19 50 38.0 %
Date: 2022-04-21 14:51:19 Functions: 3 16 18.8 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 4 6 66.7 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
#       2                 :            : // Use of this source code is governed by a BSD-style license that can be
#       3                 :            : // found in the LICENSE file. See the AUTHORS file for names of contributors.
#       4                 :            : 
#       5                 :            : #include "leveldb/iterator.h"
#       6                 :            : 
#       7                 :            : namespace leveldb {
#       8                 :            : 
#       9                 :    3506597 : Iterator::Iterator() {
#      10                 :    3506597 :   cleanup_head_.function = nullptr;
#      11                 :    3506597 :   cleanup_head_.next = nullptr;
#      12                 :    3506597 : }
#      13                 :            : 
#      14                 :    3506598 : Iterator::~Iterator() {
#      15         [ +  + ]:    3506598 :   if (!cleanup_head_.IsEmpty()) {
#      16                 :     112565 :     cleanup_head_.Run();
#      17         [ -  + ]:     112565 :     for (CleanupNode* node = cleanup_head_.next; node != nullptr;) {
#      18                 :          0 :       node->Run();
#      19                 :          0 :       CleanupNode* next_node = node->next;
#      20                 :          0 :       delete node;
#      21                 :          0 :       node = next_node;
#      22                 :          0 :     }
#      23                 :     112565 :   }
#      24                 :    3506598 : }
#      25                 :            : 
#      26                 :     112566 : void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) {
#      27                 :     112566 :   assert(func != nullptr);
#      28                 :          0 :   CleanupNode* node;
#      29         [ +  - ]:     112566 :   if (cleanup_head_.IsEmpty()) {
#      30                 :     112566 :     node = &cleanup_head_;
#      31                 :     112566 :   } else {
#      32                 :          0 :     node = new CleanupNode();
#      33                 :          0 :     node->next = cleanup_head_.next;
#      34                 :          0 :     cleanup_head_.next = node;
#      35                 :          0 :   }
#      36                 :     112566 :   node->function = func;
#      37                 :     112566 :   node->arg1 = arg1;
#      38                 :     112566 :   node->arg2 = arg2;
#      39                 :     112566 : }
#      40                 :            : 
#      41                 :            : namespace {
#      42                 :            : 
#      43                 :            : class EmptyIterator : public Iterator {
#      44                 :            :  public:
#      45                 :          0 :   EmptyIterator(const Status& s) : status_(s) {}
#      46                 :          0 :   ~EmptyIterator() override = default;
#      47                 :            : 
#      48                 :          0 :   bool Valid() const override { return false; }
#      49                 :          0 :   void Seek(const Slice& target) override {}
#      50                 :          0 :   void SeekToFirst() override {}
#      51                 :          0 :   void SeekToLast() override {}
#      52                 :          0 :   void Next() override { assert(false); }
#      53                 :          0 :   void Prev() override { assert(false); }
#      54                 :          0 :   Slice key() const override {
#      55                 :          0 :     assert(false);
#      56                 :          0 :     return Slice();
#      57                 :          0 :   }
#      58                 :          0 :   Slice value() const override {
#      59                 :          0 :     assert(false);
#      60                 :          0 :     return Slice();
#      61                 :          0 :   }
#      62                 :          0 :   Status status() const override { return status_; }
#      63                 :            : 
#      64                 :            :  private:
#      65                 :            :   Status status_;
#      66                 :            : };
#      67                 :            : 
#      68                 :            : }  // anonymous namespace
#      69                 :            : 
#      70                 :          0 : Iterator* NewEmptyIterator() { return new EmptyIterator(Status::OK()); }
#      71                 :            : 
#      72                 :          0 : Iterator* NewErrorIterator(const Status& status) {
#      73                 :          0 :   return new EmptyIterator(status);
#      74                 :          0 : }
#      75                 :            : 
#      76                 :            : }  // namespace leveldb

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a