LCOV - code coverage report
Current view: top level - src/engraving/dom - cleflist.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 93.8 % 32 30
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "cleflist.h"
      24              : 
      25              : using namespace mu;
      26              : 
      27              : namespace mu::engraving {
      28              : //---------------------------------------------------------
      29              : //   ClefTypeList::operator==
      30              : //---------------------------------------------------------
      31              : 
      32            0 : bool ClefTypeList::operator==(const ClefTypeList& t) const
      33              : {
      34            0 :     return t.concertClef == concertClef && t.transposingClef == transposingClef;
      35              : }
      36              : 
      37              : //---------------------------------------------------------
      38              : //   ClefTypeList::operator!=
      39              : //---------------------------------------------------------
      40              : 
      41            1 : bool ClefTypeList::operator!=(const ClefTypeList& t) const
      42              : {
      43            1 :     return t.concertClef != concertClef || t.transposingClef != transposingClef;
      44              : }
      45              : 
      46              : //---------------------------------------------------------
      47              : //   clef
      48              : //---------------------------------------------------------
      49              : 
      50        89659 : ClefTypeList ClefList::clef(int tick) const
      51              : {
      52        89659 :     if (empty()) {
      53        49285 :         return ClefTypeList(ClefType::INVALID, ClefType::INVALID);
      54              :     }
      55        40374 :     auto i = upper_bound(tick);
      56        40374 :     if (i == begin()) {
      57         5224 :         return ClefTypeList(ClefType::INVALID, ClefType::INVALID);
      58              :     }
      59        35150 :     return (--i)->second;
      60              : }
      61              : 
      62              : //---------------------------------------------------------
      63              : //   setClef
      64              : //---------------------------------------------------------
      65              : 
      66         1682 : void ClefList::setClef(int tick, ClefTypeList ctl)
      67              : {
      68         1682 :     auto i = find(tick);
      69         1682 :     if (i == end()) {
      70         1620 :         insert(std::pair<int, ClefTypeList>(tick, ctl));
      71              :     } else {
      72           62 :         i->second = ctl;
      73              :     }
      74         1682 : }
      75              : 
      76              : //---------------------------------------------------------
      77              : //   nextClefTick
      78              : //
      79              : //    return the tick at which the clef after tick is located
      80              : //    return -1, if no such clef
      81              : //---------------------------------------------------------
      82              : 
      83           57 : int ClefList::nextClefTick(int tick) const
      84              : {
      85           57 :     if (empty()) {
      86           17 :         return -1;
      87              :     }
      88           40 :     auto i = upper_bound(tick + 1);
      89           40 :     if (i == end()) {
      90           39 :         return -1;
      91              :     }
      92            1 :     return i->first;
      93              : }
      94              : 
      95              : //---------------------------------------------------------
      96              : //   currentClefTick
      97              : //
      98              : //    return the tick position of the clef currently
      99              : //    in effect at tick
     100              : //---------------------------------------------------------
     101              : 
     102        13300 : int ClefList::currentClefTick(int tick) const
     103              : {
     104        13300 :     if (empty()) {
     105         7630 :         return 0;
     106              :     }
     107         5670 :     auto i = upper_bound(tick);
     108         5670 :     if (i == begin()) {
     109           65 :         return 0;
     110              :     }
     111         5605 :     --i;
     112         5605 :     return i->first;
     113              : }
     114              : }
        

Generated by: LCOV version 2.0-1