Skip to content

Commit e0ae172

Browse files
chore(profiling): run clang-format
1 parent e612f48 commit e0ae172

File tree

18 files changed

+727
-915
lines changed

18 files changed

+727
-915
lines changed

ddtrace/internal/datadog/profiling/stack_v2/echion/echion/cache.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@
1313

1414
#define CACHE_MAX_ENTRIES 2048
1515

16-
template <typename K, typename V>
16+
template<typename K, typename V>
1717
class LRUCache
1818
{
19-
public:
20-
LRUCache(size_t capacity) : capacity(capacity) {}
19+
public:
20+
LRUCache(size_t capacity)
21+
: capacity(capacity)
22+
{
23+
}
2124

2225
Result<std::reference_wrapper<V>> lookup(const K& k);
2326

2427
void store(const K& k, std::unique_ptr<V> v);
2528

26-
private:
29+
private:
2730
size_t capacity;
2831
std::list<std::pair<K, std::unique_ptr<V>>> items;
2932
std::unordered_map<K, typename std::list<std::pair<K, std::unique_ptr<V>>>::iterator> index;
3033
};
3134

32-
template <typename K, typename V>
33-
void LRUCache<K, V>::store(const K& k, std::unique_ptr<V> v)
35+
template<typename K, typename V>
36+
void
37+
LRUCache<K, V>::store(const K& k, std::unique_ptr<V> v)
3438
{
3539
// Check if cache is full
36-
if (items.size() >= capacity)
37-
{
40+
if (items.size() >= capacity) {
3841
index.erase(items.back().first);
3942
items.pop_back();
4043
}
@@ -46,8 +49,9 @@ void LRUCache<K, V>::store(const K& k, std::unique_ptr<V> v)
4649
index[k] = items.begin();
4750
}
4851

49-
template <typename K, typename V>
50-
Result<std::reference_wrapper<V>> LRUCache<K, V>::lookup(const K& k)
52+
template<typename K, typename V>
53+
Result<std::reference_wrapper<V>>
54+
LRUCache<K, V>::lookup(const K& k)
5155
{
5256
auto itr = index.find(k);
5357
if (itr == index.end())

ddtrace/internal/datadog/profiling/stack_v2/echion/echion/config.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ inline bool ignore_non_running_threads = true;
2121
inline unsigned int max_frames = 2048;
2222

2323
// ----------------------------------------------------------------------------
24-
static PyObject* set_interval(PyObject* Py_UNUSED(m), PyObject* args)
24+
static PyObject*
25+
set_interval(PyObject* Py_UNUSED(m), PyObject* args)
2526
{
2627
unsigned int new_interval;
2728
if (!PyArg_ParseTuple(args, "I", &new_interval))
@@ -33,19 +34,22 @@ static PyObject* set_interval(PyObject* Py_UNUSED(m), PyObject* args)
3334
}
3435

3536
// ----------------------------------------------------------------------------
36-
inline void _set_cpu(int new_cpu)
37+
inline void
38+
_set_cpu(int new_cpu)
3739
{
3840
cpu = new_cpu;
3941
}
4042

4143
// ----------------------------------------------------------------------------
42-
inline void _set_ignore_non_running_threads(bool new_ignore_non_running_threads)
44+
inline void
45+
_set_ignore_non_running_threads(bool new_ignore_non_running_threads)
4346
{
4447
ignore_non_running_threads = new_ignore_non_running_threads;
4548
}
4649

4750
// ----------------------------------------------------------------------------
48-
static PyObject* set_cpu(PyObject* Py_UNUSED(m), PyObject* args)
51+
static PyObject*
52+
set_cpu(PyObject* Py_UNUSED(m), PyObject* args)
4953
{
5054
int new_cpu;
5155
if (!PyArg_ParseTuple(args, "p", &new_cpu))
@@ -57,7 +61,8 @@ static PyObject* set_cpu(PyObject* Py_UNUSED(m), PyObject* args)
5761
}
5862

5963
// ----------------------------------------------------------------------------
60-
static PyObject* set_max_frames(PyObject* Py_UNUSED(m), PyObject* args)
64+
static PyObject*
65+
set_max_frames(PyObject* Py_UNUSED(m), PyObject* args)
6166
{
6267
unsigned int new_max_frames;
6368
if (!PyArg_ParseTuple(args, "I", &new_max_frames))

ddtrace/internal/datadog/profiling/stack_v2/echion/echion/cpython/tasks.h

Lines changed: 196 additions & 199 deletions
Large diffs are not rendered by default.

ddtrace/internal/datadog/profiling/stack_v2/echion/echion/errors.h

Lines changed: 53 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -28,70 +28,55 @@ enum class ErrorKind
2828
RendererError,
2929
};
3030

31-
template <typename T>
31+
template<typename T>
3232
class [[nodiscard]] Result
3333
{
34-
public:
34+
public:
3535
// Factories
36-
static Result ok(const T& v)
37-
{
38-
return Result(v);
39-
}
40-
static Result ok(T&& v)
41-
{
42-
return Result(std::move(v));
43-
}
44-
static Result error(ErrorKind e) noexcept
45-
{
46-
return Result(e);
47-
}
36+
static Result ok(const T& v) { return Result(v); }
37+
static Result ok(T&& v) { return Result(std::move(v)); }
38+
static Result error(ErrorKind e) noexcept { return Result(e); }
4839

4940
// Constructors
50-
Result(const T& v) noexcept(std::is_nothrow_copy_constructible<T>::value) : success_(true)
41+
Result(const T& v) noexcept(std::is_nothrow_copy_constructible<T>::value)
42+
: success_(true)
5143
{
5244
::new (static_cast<void*>(std::addressof(value_))) T(v);
5345
}
5446

55-
Result(T&& v) noexcept(std::is_nothrow_move_constructible<T>::value) : success_(true)
47+
Result(T&& v) noexcept(std::is_nothrow_move_constructible<T>::value)
48+
: success_(true)
5649
{
5750
::new (static_cast<void*>(std::addressof(value_))) T(std::move(v));
5851
}
5952

60-
Result(ErrorKind e) noexcept : success_(false)
53+
Result(ErrorKind e) noexcept
54+
: success_(false)
6155
{
6256
error_ = e;
6357
}
6458

6559
// Destructor
66-
~Result()
67-
{
68-
reset();
69-
}
60+
~Result() { reset(); }
7061

7162
// Copy ctor
7263
Result(const Result& other) noexcept(std::is_nothrow_copy_constructible<T>::value)
73-
: success_(other.success_)
64+
: success_(other.success_)
7465
{
75-
if (success_)
76-
{
66+
if (success_) {
7767
::new (static_cast<void*>(std::addressof(value_))) T(other.value_);
78-
}
79-
else
80-
{
68+
} else {
8169
error_ = other.error_;
8270
}
8371
}
8472

8573
// Move ctor
8674
Result(Result&& other) noexcept(std::is_nothrow_move_constructible<T>::value)
87-
: success_(other.success_)
75+
: success_(other.success_)
8876
{
89-
if (success_)
90-
{
77+
if (success_) {
9178
::new (static_cast<void*>(std::addressof(value_))) T(std::move(other.value_));
92-
}
93-
else
94-
{
79+
} else {
9580
error_ = other.error_;
9681
}
9782
}
@@ -103,23 +88,16 @@ class [[nodiscard]] Result
10388
if (this == &other)
10489
return *this;
10590

106-
if (success_ && other.success_)
107-
{
91+
if (success_ && other.success_) {
10892
value_ = other.value_;
109-
}
110-
else if (success_ && !other.success_)
111-
{
93+
} else if (success_ && !other.success_) {
11294
value_.~T();
11395
success_ = false;
11496
error_ = other.error_;
115-
}
116-
else if (!success_ && other.success_)
117-
{
97+
} else if (!success_ && other.success_) {
11898
::new (static_cast<void*>(std::addressof(value_))) T(other.value_);
11999
success_ = true;
120-
}
121-
else
122-
{ // both errors
100+
} else { // both errors
123101
error_ = other.error_;
124102
}
125103
return *this;
@@ -132,75 +110,44 @@ class [[nodiscard]] Result
132110
if (this == &other)
133111
return *this;
134112

135-
if (success_ && other.success_)
136-
{
113+
if (success_ && other.success_) {
137114
value_ = std::move(other.value_);
138-
}
139-
else if (success_ && !other.success_)
140-
{
115+
} else if (success_ && !other.success_) {
141116
value_.~T();
142117
success_ = false;
143118
error_ = other.error_;
144-
}
145-
else if (!success_ && other.success_)
146-
{
119+
} else if (!success_ && other.success_) {
147120
::new (static_cast<void*>(std::addressof(value_))) T(std::move(other.value_));
148121
success_ = true;
149-
}
150-
else
151-
{ // both errors
122+
} else { // both errors
152123
error_ = other.error_;
153124
}
154125
return *this;
155126
}
156127

157128
// Observers
158-
explicit operator bool() const noexcept
159-
{
160-
return success_;
161-
}
129+
explicit operator bool() const noexcept { return success_; }
162130

163-
T& operator*() &
164-
{
165-
return value_;
166-
}
167-
const T& operator*() const&
168-
{
169-
return value_;
170-
}
171-
T&& operator*() &&
172-
{
173-
return std::move(value_);
174-
}
131+
T& operator*() & { return value_; }
132+
const T& operator*() const& { return value_; }
133+
T&& operator*() && { return std::move(value_); }
175134

176-
T* operator->()
177-
{
178-
return std::addressof(value_);
179-
}
180-
const T* operator->() const
181-
{
182-
return std::addressof(value_);
183-
}
135+
T* operator->() { return std::addressof(value_); }
136+
const T* operator->() const { return std::addressof(value_); }
184137

185-
bool has_value() const noexcept
186-
{
187-
return success_;
188-
}
138+
bool has_value() const noexcept { return success_; }
189139

190140
// If in error, returns default_value
191-
template <typename U>
141+
template<typename U>
192142
T value_or(U&& default_value) const
193143
{
194144
return success_ ? value_ : static_cast<T>(std::forward<U>(default_value));
195145
}
196146

197147
// Returns ErrorKind::Undefined when holding a value
198-
ErrorKind error() const noexcept
199-
{
200-
return success_ ? ErrorKind::Undefined : error_;
201-
}
148+
ErrorKind error() const noexcept { return success_ ? ErrorKind::Undefined : error_; }
202149

203-
private:
150+
private:
204151
// Active member is tracked by success_
205152
union
206153
{
@@ -211,46 +158,38 @@ class [[nodiscard]] Result
211158

212159
void reset() noexcept
213160
{
214-
if (success_)
215-
{
161+
if (success_) {
216162
value_.~T();
217163
}
218164
}
219165
};
220166

221167
// Specialization for void
222-
template <>
168+
template<>
223169
class [[nodiscard]] Result<void>
224170
{
225-
public:
226-
static Result ok() noexcept
171+
public:
172+
static Result ok() noexcept { return Result(true, ErrorKind::Undefined); }
173+
static Result error(ErrorKind e) noexcept { return Result(false, e); }
174+
Result(ErrorKind e) noexcept
175+
: success_(false)
176+
, error_(e)
227177
{
228-
return Result(true, ErrorKind::Undefined);
229178
}
230-
static Result error(ErrorKind e) noexcept
231-
{
232-
return Result(false, e);
233-
}
234-
Result(ErrorKind e) noexcept : success_(false), error_(e) {}
235179

236-
explicit operator bool() const noexcept
237-
{
238-
return success_;
239-
}
240-
bool has_value() const noexcept
241-
{
242-
return success_;
243-
}
180+
explicit operator bool() const noexcept { return success_; }
181+
bool has_value() const noexcept { return success_; }
244182

245183
// Returns ErrorKind::Undefined when success
246-
ErrorKind error() const noexcept
247-
{
248-
return success_ ? ErrorKind::Undefined : error_;
249-
}
184+
ErrorKind error() const noexcept { return success_ ? ErrorKind::Undefined : error_; }
250185

251-
private:
186+
private:
252187
bool success_;
253188
ErrorKind error_;
254189

255-
explicit Result(bool s, ErrorKind e) noexcept : success_(s), error_(e) {}
190+
explicit Result(bool s, ErrorKind e) noexcept
191+
: success_(s)
192+
, error_(e)
193+
{
194+
}
256195
};

0 commit comments

Comments
 (0)