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

STEllAR-GROUP / hpx / #862

10 Jan 2023 05:30PM UTC coverage: 86.582% (-0.05%) from 86.634%
#862

push

StellarBot
Merge #6130

6130: Remove the mutex lock in the critical path of get_partitioner. r=hkaiser a=JiakunYan

Remove the mutex lock in the critical path of hpx::resource::detail::get_partitioner.

The protected variable `partitioner_ref` is only set once during initialization.

Co-authored-by: Jiakun Yan <jiakunyan1998@gmail.com>

6 of 6 new or added lines in 1 file covered. (100.0%)

174767 of 201851 relevant lines covered (86.58%)

2069816.07 hits per line

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

0.0
/libs/core/util/src/regex_from_pattern.cpp
1
//  Copyright (c) 2007-2017 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#include <hpx/modules/errors.hpp>
9
#include <hpx/util/regex_from_pattern.hpp>
10

11
#include <string>
12

13
namespace hpx::util {
14

15
    namespace detail {
16

17
        ///////////////////////////////////////////////////////////////////////
18
        inline std::string regex_from_character_set(
×
19
            std::string::const_iterator& it, std::string::const_iterator end,
20
            error_code& ec)
21
        {
22
            std::string::const_iterator start = it;
×
23
            std::string result(1, *it);    // copy '['
×
24
            if (++it != end)
×
25
            {
26
                if (*it == '!')
×
27
                {
28
                    result.append(1, '^');    // negated character set
×
29
                }
×
30
                else if (*it == ']')
×
31
                {
32
                    HPX_THROWS_IF(ec, hpx::error::bad_parameter,
×
33
                        "regex_from_character_set",
34
                        "Invalid pattern (empty character set) at: {}",
35
                        std::string(start, end));
36
                    return "";
×
37
                }
38
                else
39
                {
40
                    result.append(1, *it);    // append this character
×
41
                }
42
            }
×
43

44
            // copy while in character set
45
            while (++it != end)
×
46
            {
47
                result.append(1, *it);
×
48
                if (*it == ']')
×
49
                    break;
×
50
            }
51

52
            if (it == end || *it != ']')
×
53
            {
54
                HPX_THROWS_IF(ec, hpx::error::bad_parameter,
×
55
                    "regex_from_character_set",
56
                    "Invalid pattern (missing closing ']') at: {}",
57
                    std::string(start, end));
58
                return "";
×
59
            }
60

61
            return result;
×
62
        }
×
63
    }    // namespace detail
64

65
    std::string regex_from_pattern(std::string const& pattern, error_code& ec)
×
66
    {
67
        std::string result;
×
68
        std::string::const_iterator end = pattern.end();
×
69
        for (std::string::const_iterator it = pattern.begin(); it != end; ++it)
×
70
        {
71
            char c = *it;
×
72
            switch (c)
×
73
            {
74
            case '*':
75
                result.append(".*");
×
76
                break;
×
77

78
            case '?':
79
                result.append(1, '.');
×
80
                break;
×
81

82
            case '[':
83
            {
84
                std::string r = detail::regex_from_character_set(it, end, ec);
×
85
                if (ec)
×
86
                    return "";
×
87
                result.append(r);
×
88
            }
×
89
            break;
×
90

91
            case '\\':
92
                if (++it == end)
×
93
                {
94
                    HPX_THROWS_IF(ec, hpx::error::bad_parameter,
×
95
                        "regex_from_pattern", "Invalid escape sequence at: {}",
96
                        pattern);
97
                    return "";
×
98
                }
99
                result.append(1, *it);
×
100
                break;
×
101

102
            // escape regex special characters
103
            // NOLINTNEXTLINE(bugprone-branch-clone)
104
            case '+':
105
                [[fallthrough]];
106
            case '.':
107
                [[fallthrough]];
108
            case '(':
109
                [[fallthrough]];
110
            case ')':
111
                [[fallthrough]];
112
            case '{':
113
                [[fallthrough]];
114
            case '}':
115
                [[fallthrough]];
116
            case '^':
117
                [[fallthrough]];
118
            case '$':
119
                result.append("\\");
×
120
                [[fallthrough]];
121

122
            default:
123
                result.append(1, c);
×
124
                break;
×
125
            }
126
        }
×
127
        return result;
×
128
    }
×
129
}    // namespace hpx::util
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

© 2025 Coveralls, Inc