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

realm / realm-core / 1794

31 Oct 2023 10:48PM UTC coverage: 91.584% (+0.02%) from 91.565%
1794

push

Evergreen

web-flow
remove unnecessary callback use for ArrayWithFind::find_action() (#7095)

* remove unnecessary callback use for ArrayWithFind::find_action()

* remove find_action_pattern which hasn't been used in years

* add changeloge note

* lint and address comments

92898 of 170898 branches covered (0.0%)

107 of 126 new or added lines in 10 files covered. (84.92%)

47 existing lines in 13 files now uncovered.

230666 of 251863 relevant lines covered (91.58%)

6855264.67 hits per line

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

55.1
/src/realm/array_with_find.cpp
1
/*************************************************************************
2
 *
3
 * Copyright 2021 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#include <realm/array_with_find.hpp>
20

21
namespace realm {
22

23
void ArrayWithFind::find_all(IntegerColumn* result, int64_t value, size_t col_offset, size_t begin, size_t end) const
24
{
102✔
25
    REALM_ASSERT_3(begin, <=, m_array.size());
102✔
26
    REALM_ASSERT(end == npos || (begin <= end && end <= m_array.size()));
102✔
27

51✔
28
    if (end == npos)
102✔
29
        end = m_array.m_size;
90✔
30

51✔
31
    QueryStateFindAll state(*result);
102✔
32
    REALM_TEMPEX2(find_optimized, Equal, m_array.m_width, (value, begin, end, col_offset, &state));
102✔
33

51✔
34
    return;
102✔
35
}
102✔
36

37

38
bool ArrayWithFind::find(int cond, int64_t value, size_t start, size_t end, size_t baseindex,
39
                         QueryStateBase* state) const
40
{
×
41
    if (cond == cond_Equal) {
×
NEW
42
        return find<Equal>(value, start, end, baseindex, state);
×
43
    }
×
44
    if (cond == cond_NotEqual) {
×
NEW
45
        return find<NotEqual>(value, start, end, baseindex, state);
×
46
    }
×
47
    if (cond == cond_Greater) {
×
NEW
48
        return find<Greater>(value, start, end, baseindex, state);
×
49
    }
×
50
    if (cond == cond_Less) {
×
NEW
51
        return find<Less>(value, start, end, baseindex, state);
×
52
    }
×
53
    if (cond == cond_None) {
×
NEW
54
        return find<None>(value, start, end, baseindex, state);
×
55
    }
×
56
    else if (cond == cond_LeftNotNull) {
×
NEW
57
        return find<NotNull>(value, start, end, baseindex, state);
×
58
    }
×
59
    REALM_ASSERT_DEBUG(false);
×
60
    return false;
×
61
}
×
62

63
size_t ArrayWithFind::first_set_bit(uint32_t v) const
64
{
27,778,713✔
65
    // (v & -v) is UB when v is INT_MIN
23,699,259✔
66
    if (int32_t(v) == std::numeric_limits<int32_t>::min())
27,778,713✔
67
        return 31;
240,879✔
68
    static const int MultiplyDeBruijnBitPosition[32] = {0,  1,  28, 2,  29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4,  8,
27,537,834✔
69
                                                        31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6,  11, 5,  10, 9};
27,537,834✔
70
    return MultiplyDeBruijnBitPosition[(uint32_t((v & -int32_t(v)) * 0x077CB531U)) >> 27];
27,537,834✔
71
}
27,537,834✔
72

73
size_t ArrayWithFind::first_set_bit64(int64_t v) const
74
{
4,099,836✔
75
    unsigned int v0 = unsigned(v);
4,099,836✔
76
    if (v0 != 0)
4,099,836✔
77
        return first_set_bit(v0);
3,955,590✔
78
    unsigned int v1 = unsigned(uint64_t(v) >> 32);
144,246✔
79
    return first_set_bit(v1) + 32;
144,246✔
80
}
144,246✔
81

82

83
} // namespace realm
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