• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 16177389448

09 Jul 2025 06:34PM UTC coverage: 86.652% (-0.02%) from 86.675%
16177389448

Pull #559

github

web-flow
Merge 7c77ed725 into 6face81ba
Pull Request #559: wip - bad performances

8 of 11 new or added lines in 2 files covered. (72.73%)

2 existing lines in 1 file now uncovered.

7297 of 8421 relevant lines covered (86.65%)

113291.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.71
/src/arkreactor/VM/ScopeView.cpp
1
#include <Ark/VM/ScopeView.hpp>
2

3
#include <limits>
4

5
namespace Ark::internal
6
{
7
    ScopeView::ScopeView(pair_t* storage, const std::size_t start) noexcept :
140,852✔
8
        m_storage(storage), m_start(start), m_size(0), m_min_id(std::numeric_limits<uint16_t>::max()), m_max_id(0)
140,852✔
9
    {}
281,704✔
10

11
    bool ScopeView::push_back(uint16_t id, Value&& val) noexcept
28,998✔
12
    {
28,998✔
13
        if (m_start + m_size >= ScopeStackSize) [[unlikely]]
28,998✔
NEW
UNCOV
14
            return false;
×
15

16
        if (id < m_min_id)
28,998✔
17
            m_min_id = id;
5,255✔
18
        if (id > m_max_id)
28,998✔
19
            m_max_id = id;
22,569✔
20

21
        m_storage[m_start + m_size] = std::make_pair(id, std::move(val));
28,998✔
22
        ++m_size;
28,998✔
23
        return true;
28,998✔
24
    }
28,998✔
25

26
    bool ScopeView::push_back(uint16_t id, const Value& val) noexcept
370,486✔
27
    {
370,486✔
28
        if (m_start + m_size >= ScopeStackSize) [[unlikely]]
370,486✔
NEW
UNCOV
29
            return false;
×
30

31
        if (id < m_min_id)
370,486✔
32
            m_min_id = id;
148,277✔
33
        if (id > m_max_id)
370,486✔
34
            m_max_id = id;
237,295✔
35

36
        m_storage[m_start + m_size] = std::make_pair(id, val);
370,486✔
37
        ++m_size;
370,486✔
38
        return true;
370,486✔
39
    }
370,486✔
40

41
    bool ScopeView::maybeHas(const uint16_t id) const noexcept
1,202,041✔
42
    {
1,202,041✔
43
        return m_min_id <= id && id <= m_max_id;
1,202,041✔
44
    }
45

46
    Value* ScopeView::operator[](const uint16_t id_to_look_for) noexcept
1,202,043✔
47
    {
1,202,043✔
48
        if (!maybeHas(id_to_look_for))
1,202,043✔
49
            return nullptr;
571,118✔
50

51
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
3,688,304✔
52
        {
53
            auto& [id, value] = m_storage[i];
3,057,379✔
54
            if (id == id_to_look_for)
3,057,379✔
55
                return &value;
582,053✔
56
        }
3,057,379✔
57
        return nullptr;
48,872✔
58
    }
1,202,043✔
59

60
    const Value* ScopeView::operator[](const uint16_t id_to_look_for) const noexcept
×
61
    {
×
62
        if (!maybeHas(id_to_look_for))
×
63
            return nullptr;
×
64

65
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
×
66
        {
67
            auto& [id, value] = m_storage[i];
×
68
            if (id == id_to_look_for)
×
69
                return &value;
×
70
        }
×
71
        return nullptr;
×
72
    }
×
73

74
    uint16_t ScopeView::idFromValue(const Value& val) const noexcept
2,047✔
75
    {
2,047✔
76
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
4,094✔
77
        {
78
            const auto& [id, value] = m_storage[i];
4,094✔
79
            if (value == val)
2,047✔
80
                return id;
2,047✔
81
        }
2,047✔
82
        return std::numeric_limits<uint16_t>::max();
×
83
    }
2,047✔
84

85
    void ScopeView::reset() noexcept
30,897✔
86
    {
30,897✔
87
        m_size = 0;
30,897✔
88
        m_min_id = std::numeric_limits<uint16_t>::max();
30,897✔
89
        m_max_id = 0;
30,897✔
90
    }
30,897✔
91

92
    bool operator==(const ScopeView& A, const ScopeView& B) noexcept
×
93
    {
×
94
        // if we have two scopes with the same number of elements and starting at the same position,
95
        // they must be identical, as we have a single storage for all scopes
96
        return A.m_size == B.m_size && A.m_start == B.m_start;
×
97
    }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc