Skip to content

Commit 3aac9a8

Browse files
committed
fixed various clang tidy warnings
1 parent bab62af commit 3aac9a8

27 files changed

+294
-300
lines changed

Diff for: .benchmark/benchmark.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ namespace jluna
2525
struct Result
2626
{
2727
Result()
28-
: _name(""),
29-
_min(0),
28+
: _min(0),
3029
_max(0),
3130
_average(0),
3231
_median(0),
@@ -165,7 +164,7 @@ namespace jluna
165164
std::cout << "│ Max : " << max << "ms" << std::endl;
166165
std::cout << "│ Median : " << med << "ms" << std::endl;
167166
std::cout << "" << std::endl;
168-
std::cout << "│ Overhead: " << (res._overhead * 100) << "%" << std::endl;
167+
std::cout << "│ Overhead: " << (res._overhead * 100.f) << "%" << std::endl;
169168

170169
if (res._exception_maybe != "")
171170
{

Diff for: .benchmark/main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,29 @@ int main()
8383
// C-API
8484
Benchmark::run_as_base("C-API: set", n_reps, [](){
8585

86-
Int64 to_box = generate_number<Int64>();
86+
auto to_box = generate_number<Int64>();
8787
jl_set_global(jl_main_module, "x"_sym, jl_box_int64(to_box));
8888
});
8989

9090
// unsafe
9191
Benchmark::run("unsafe: set", n_reps, [](){
9292

93-
Int64 to_box = generate_number<Int64>();
93+
auto to_box = generate_number<Int64>();
9494
unsafe::set_value(jl_main_module, "x"_sym, unsafe::unsafe_box<Int64>(to_box));
9595
});
9696

9797
// Module::assign
9898
Benchmark::run("Module::assign", n_reps / 10, [](){
9999

100-
Int64 to_box = generate_number<Int64>();
100+
auto to_box = generate_number<Int64>();
101101
Main.assign("x", to_box);
102102
});
103103

104104
// Proxy::operator=
105105
auto x_proxy = Main["x"];
106106
Benchmark::run("Proxy::operator=", n_reps / 10, [&](){
107107

108-
Int64 to_box = generate_number<Int64>();
108+
auto to_box = generate_number<Int64>();
109109
x_proxy = to_box;
110110
});
111111

@@ -304,7 +304,7 @@ int main()
304304
// run task using std::thread
305305
Benchmark::run("threading: std::thread", n_reps, [&]()
306306
{
307-
queue.emplace(std::packaged_task<void()>(task));
307+
queue.emplace(task);
308308
queue_cv.notify_all();
309309
master_cv.wait(master_lock, [](){
310310
return queue.empty();

Diff for: .src/c_adapter.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
#pragma once
77

8-
#include <stddef.h>
9-
108
#include <include/julia_wrapper.hpp>
9+
10+
#include <cstddef>
1111
#include <functional>
1212
#include <string>
1313

Diff for: .src/common.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace jluna::detail
2727
inline std::string to_string(unsafe::Value* value)
2828
{
2929
static auto* string = unsafe::get_function(jl_base_module, "string"_sym);
30-
return std::string(jl_string_ptr(unsafe::call(string, value)));
30+
return {jl_string_ptr(unsafe::call(string, value))};
3131
}
3232

3333
inline void assert_type(unsafe::DataType* type_a, unsafe::DataType* type_b)

Diff for: .src/exceptions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace jluna
1414
{
15-
JuliaException::JuliaException(jl_value_t* exception, std::string stacktrace)
15+
JuliaException::JuliaException(jl_value_t* exception, const std::string& stacktrace)
1616
: _value(exception), _message("[JULIA][EXCEPTION] " + stacktrace)
1717
{}
1818

Diff for: .src/generator_expression.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace jluna
1818
auto* res = jl_eval_string(in);
1919
forward_last_exception();
2020

21-
static jl_datatype_t* generator_type = (jl_datatype_t*) jl_eval_string("Base.Generator");
21+
static auto* generator_type = (jl_datatype_t*) jl_eval_string("Base.Generator");
2222
if (not jl_isa(res, (unsafe::Value*) generator_type))
2323
{
2424
std::stringstream error_str;
@@ -84,7 +84,7 @@ namespace jluna
8484
unsafe::Value* GeneratorExpression::ForwardIterator::operator*()
8585
{
8686
gc_pause;
87-
auto* out = jl_get_nth_field(jl_call2(_owner->_iterate, _owner->get(), jl_box_int64(_state)), 0);
87+
auto* out = jl_get_nth_field(jl_call2(_iterate, _owner->get(), jl_box_int64(_state)), 0);
8888
gc_unpause;
8989
return out;
9090
}
@@ -94,7 +94,7 @@ namespace jluna
9494
auto previous = _state;
9595

9696
gc_pause;
97-
auto* next = jl_call2(_owner->_iterate, _owner->get(), jl_box_int64(_state));
97+
auto* next = jl_call2(_iterate, _owner->get(), jl_box_int64(_state));
9898

9999
if (jl_is_nothing(next))
100100
_state = previous;

Diff for: .src/module.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace jluna
3838

3939
Module Module::get_parent_module() const
4040
{
41-
return Module(value()->parent);
41+
return {value()->parent};
4242
}
4343

4444
bool Module::is_top_module() const
@@ -79,7 +79,7 @@ namespace jluna
7979

8080
Symbol Module::get_symbol() const
8181
{
82-
return Symbol(value()->name);
82+
return {value()->name};
8383
}
8484

8585
void Module::initialize_lock()

Diff for: .src/multi_threading.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace jluna
1111
struct TaskValue : public detail::TaskSuper
1212
{
1313
friend class jluna::ThreadPool;
14-
TaskValue(size_t);
14+
explicit TaskValue(size_t);
1515
~TaskValue();
1616

1717
void free() override;

Diff for: .src/proxy.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace jluna
8484
return nullptr; // unreachable
8585
}
8686

87-
unsafe::Value* Proxy::ProxyValue::get_field(jl_sym_t* symbol)
87+
unsafe::Value* Proxy::ProxyValue::get_field(jl_sym_t* symbol) const
8888
{
8989
static jl_function_t* dot = unsafe::get_function("jluna"_sym, "dot"_sym);
9090

@@ -131,7 +131,7 @@ namespace jluna
131131
else
132132
out = jluna::safe_call(getindex, v, box<size_t>(i + 1));
133133

134-
return Proxy(out, _content, jl_box_uint64(i+1));
134+
return {out, _content, jl_box_uint64(i+1)};
135135
}
136136

137137
Proxy::operator unsafe::Value*()
@@ -155,7 +155,7 @@ namespace jluna
155155
Proxy::operator std::string() const
156156
{
157157
static jl_function_t* to_string = jl_get_function(jl_base_module, "string");
158-
return std::string(jl_string_data(jl_call1(to_string, _content->value())));
158+
return {jl_string_data(jl_call1(to_string, _content->value()))};
159159
}
160160

161161
std::string Proxy::get_name() const
@@ -170,15 +170,15 @@ namespace jluna
170170
auto* svec = jl_field_names((jl_datatype_t*) (jl_isa(_content->value(), (unsafe::Value*) jl_datatype_type) ? _content->value() : jl_typeof(_content->value())));
171171
std::vector<std::string> out;
172172
for (size_t i = 0; i < jl_svec_len(svec); ++i)
173-
out.push_back(std::string(jl_symbol_name((jl_sym_t*) jl_svecref(svec, i))));
173+
out.emplace_back(jl_symbol_name((jl_sym_t*) jl_svecref(svec, i)));
174174

175175
gc_unpause;
176176
return out;
177177
}
178178

179179
Type Proxy::get_type() const
180180
{
181-
return Type((jl_datatype_t*) jl_typeof(_content->value()));
181+
return {(jl_datatype_t*) jl_typeof(_content->value())};
182182
}
183183

184184
bool Proxy::is_mutating() const
@@ -204,7 +204,7 @@ namespace jluna
204204
Proxy Proxy::as_unnamed() const
205205
{
206206
static auto* deepcopy = unsafe::get_function(jl_base_module, "deepcopy"_sym);
207-
return Proxy(unsafe::call(deepcopy, _content->value()), nullptr);
207+
return {unsafe::call(deepcopy, _content->value()), nullptr};
208208
}
209209

210210
void Proxy::update()

Diff for: .src/safe_utilities.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ namespace jluna
135135

136136
std::stringstream str;
137137
str << "jluna.cppcall.eval(:(const _lib = \""
138-
<< (jluna_shared_library_path == "" ? jluna::detail::shared_library_name : jluna_shared_library_path)
138+
<< (jluna_shared_library_path.empty() ? jluna::detail::shared_library_name : jluna_shared_library_path)
139139
<< "\"))";
140140

141141
jl_eval_string(str.str().c_str());

Diff for: .src/type.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace jluna
1111
Type::Type() = default;
1212

1313
Type::Type(jl_datatype_t* value)
14-
: Proxy((unsafe::Value*) value, (value->name == NULL ? jl_symbol("Union{}") : value->name->name))
14+
: Proxy((unsafe::Value*) value, (value->name == nullptr ? jl_symbol("Union{}") : value->name->name))
1515
{}
1616

1717
Type::Type(Proxy* owner)
@@ -23,7 +23,7 @@ namespace jluna
2323
Type Type::unroll() const
2424
{
2525
static jl_function_t* unroll = unsafe::get_function("jluna"_sym, "unroll_type"_sym);
26-
return Type((jl_datatype_t*) jluna::safe_call(unroll, get()));
26+
return {(jl_datatype_t*) jluna::safe_call(unroll, get())};
2727
}
2828

2929
Type::operator jl_datatype_t*()
@@ -38,7 +38,7 @@ namespace jluna
3838

3939
Type Type::get_super_type() const
4040
{
41-
return Type(get()->super);
41+
return {get()->super};
4242
}
4343

4444
Symbol Type::get_symbol() const

0 commit comments

Comments
 (0)