Skip to content

Commit

Permalink
Tweak coding style based on review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Jul 30, 2022
1 parent 87b96a4 commit 1808f44
Show file tree
Hide file tree
Showing 64 changed files with 406 additions and 470 deletions.
73 changes: 26 additions & 47 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,62 +1,41 @@
---
AccessModifierOffset: -2
---
AccessModifierOffset: '-2'
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Right
AlignOperands: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
AlwaysBreakTemplateDeclarations: 'Yes'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
FixNamespaceComments: true
ColumnLimit: '80'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '2'
ContinuationIndentWidth: '2'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentCaseLabels: 'true'
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
IndentWidth: '2'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MacroBlockBegin: "^BEGIN_STATE$|CAF_BEGIN_TYPE_ID_BLOCK"
MacroBlockEnd: "^END_STATE$|CAF_END_TYPE_ID_BLOCK"
MaxEmptyLinesToKeep: 1
MacroBlockBegin: ^BEGIN_STATE$|CAF_BEGIN_TYPE_ID_BLOCK
MacroBlockEnd: ^END_STATE$|CAF_END_TYPE_ID_BLOCK
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: None
PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 50
PenaltyReturnTypeOnItsOwnLine: 25
PenaltyBreakAssignment: '21'
PenaltyBreakBeforeFirstCallParameter: '60'
PenaltyReturnTypeOnItsOwnLine: '50'
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceAfterCStyleCast: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesBeforeTrailingComments: '1'
Standard: Cpp11
UseTab: Never

...
19 changes: 9 additions & 10 deletions bindings/python/_broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ PYBIND11_MODULE(_broker, m) {
init_store(m);

auto version = m.def_submodule("Version", "Version constants");
version.attr("MAJOR")
= py::cast(new broker::version::type{broker::version::major});
version.attr("MINOR")
= py::cast(new broker::version::type{broker::version::minor});
version.attr("PATCH")
= py::cast(new broker::version::type{broker::version::patch});
version.attr("PROTOCOL")
= py::cast(new broker::version::type{broker::version::protocol});
version.attr("MAJOR") =
py::cast(new broker::version::type{broker::version::major});
version.attr("MINOR") =
py::cast(new broker::version::type{broker::version::minor});
version.attr("PATCH") =
py::cast(new broker::version::type{broker::version::patch});
version.attr("PROTOCOL") =
py::cast(new broker::version::type{broker::version::protocol});
version.def("compatible", &broker::version::compatible,
"Checks whether two Broker protocol versions are compatible");

Expand Down Expand Up @@ -333,8 +333,7 @@ PYBIND11_MODULE(_broker, m) {
// created one in, which is unfortunate.
struct Configuration {
Configuration(){};
Configuration(broker::broker_options opts) : options(std::move(opts)) {
}
Configuration(broker::broker_options opts) : options(std::move(opts)) {}
broker::broker_options options = {};
std::string openssl_cafile;
std::string openssl_capath;
Expand Down
3 changes: 1 addition & 2 deletions bindings/python/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ using namespace pybind11::literals;
// A thin wrapper around the 'count' type, because Python has no notion of
// unsigned integers.
struct count_type {
count_type(broker::count c) : value{c} {
}
count_type(broker::count c) : value{c} {}
bool operator==(const count_type& other) const {
return value == other.value;
}
Expand Down
20 changes: 8 additions & 12 deletions bindings/python/set_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ PYBIND11_NAMESPACE_BEGIN(detail)
* std::pair for maps) */
template <typename T>
struct is_comparable<T, enable_if_t<container_traits<T>::is_set>> {
static constexpr const bool value
= is_comparable<typename T::value_type>::value;
static constexpr const bool value =
is_comparable<typename T::value_type>::value;
};

/* Fallback functions */
template <typename, typename, typename... Args>
void set_if_copy_constructible(const Args&...) {
}
void set_if_copy_constructible(const Args&...) {}
template <typename, typename, typename... Args>
void set_if_equal_operator(const Args&...) {
}
void set_if_equal_operator(const Args&...) {}
template <typename, typename, typename... Args>
void set_if_insertion_operator(const Args&...) {
}
void set_if_insertion_operator(const Args&...) {}
template <typename, typename, typename... Args>
void set_modifiers(const Args&...) {
}
void set_modifiers(const Args&...) {}

template <typename Set, typename Class_>
void set_if_copy_constructible(
Expand Down Expand Up @@ -118,8 +114,8 @@ PYBIND11_NAMESPACE_END(detail)
//
template <typename Set, typename holder_type = std::unique_ptr<Set>,
typename... Args>
class_<Set, holder_type>
bind_set(module& m, std::string const& name, Args&&... args) {
class_<Set, holder_type> bind_set(module& m, std::string const& name,
Args&&... args) {
using Class_ = class_<Set, holder_type>;

Class_ cl(m, name.c_str(), std::forward<Args>(args)...);
Expand Down
3 changes: 1 addition & 2 deletions doc/_examples/comm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

using namespace broker;

int main() {
}
int main() {}

void f1() {
// --get-start
Expand Down
3 changes: 1 addition & 2 deletions doc/_examples/stores.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

using namespace broker;

int main() {
}
int main() {}

void f1() {
// --attach-master-start
Expand Down
4 changes: 2 additions & 2 deletions include/broker/alm/multipath.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public:

private:
template <class MakeNewNode>
std::pair<multipath_node*, bool>
emplace_impl(const endpoint_id& id, MakeNewNode make_new_node);
std::pair<multipath_node*, bool> emplace_impl(const endpoint_id& id,
MakeNewNode make_new_node);

void shallow_delete() noexcept;

Expand Down
4 changes: 2 additions & 2 deletions include/broker/detail/abstract_backend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public:
/// @param value The value associated with *key*.
/// @param expiry An optional expiration time for the entry.
/// @returns `nil` on success.
virtual expected<void>
put(const data& key, data value, std::optional<timestamp> expiry = {}) = 0;
virtual expected<void> put(const data& key, data value,
std::optional<timestamp> expiry = {}) = 0;

/// Adds one value to another value.
/// @param key The key associated with the existing value to add to.
Expand Down
4 changes: 2 additions & 2 deletions include/broker/detail/monotonic_buffer_resource.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public:

monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;

monotonic_buffer_resource& operator=(const monotonic_buffer_resource&)
= delete;
monotonic_buffer_resource&
operator=(const monotonic_buffer_resource&) = delete;

~monotonic_buffer_resource() noexcept {
destroy();
Expand Down
4 changes: 2 additions & 2 deletions include/broker/detail/native_socket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace broker::detail {

using native_socket = size_t;

constexpr native_socket invalid_native_socket
= std::numeric_limits<native_socket>::max();
constexpr native_socket invalid_native_socket =
std::numeric_limits<native_socket>::max();

#else // BROKER_WINDOWS

Expand Down
41 changes: 15 additions & 26 deletions include/broker/detail/radix_tree.hh
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ public:
struct node_visit {
node* n;
uint16_t idx;
node_visit(node* arg_n) : n(arg_n), idx(0) {
}
node_visit(node* arg_n, uint16_t arg_i) : n(arg_n), idx(arg_i) {
}
node_visit(node* arg_n) : n(arg_n), idx(0) {}
node_visit(node* arg_n, uint16_t arg_i) : n(arg_n), idx(arg_i) {}
};

node* root;
Expand All @@ -128,8 +126,7 @@ public:
/**
* Default construct an empty container.
*/
explicit radix_tree() : num_entries(0), root(nullptr) {
}
explicit radix_tree() : num_entries(0), root(nullptr) {}

/**
* Destructor.
Expand Down Expand Up @@ -279,15 +276,13 @@ private:
node256,
};

node(tag t) : type(t) {
}
node(tag t) : type(t) {}

node(tag t, const node& other)
: type(t),
num_children(other.num_children),
partial_len(other.partial_len),
partial(other.partial) {
}
partial(other.partial) {}

tag type;
uint8_t num_children = 0;
Expand All @@ -304,8 +299,7 @@ private:
std::array<node*, 4> children = {};

node4() = default;
node4(const node& other) : n(node::tag::node4, other) {
}
node4(const node& other) : n(node::tag::node4, other) {}

void add_child(node** ref, unsigned char c, node* child);
void rem_child(node** ref, node** child);
Expand All @@ -320,8 +314,7 @@ private:
std::array<node*, 16> children = {};

node16() = default;
node16(const node& other) : n(node::tag::node16, other) {
}
node16(const node& other) : n(node::tag::node16, other) {}

void add_child(node** ref, unsigned char c, node* child);
void rem_child(node** ref, node** child);
Expand All @@ -337,8 +330,7 @@ private:
std::array<node*, 48> children = {};

node48() = default;
node48(const node& other) : n(node::tag::node48, other) {
}
node48(const node& other) : n(node::tag::node48, other) {}

void add_child(node** ref, unsigned char c, node* child);
void rem_child(node** ref, unsigned char c);
Expand All @@ -352,8 +344,7 @@ private:
std::array<node*, 256> children = {};

node256() = default;
node256(const node& other) : n(node::tag::node256, other) {
}
node256(const node& other) : n(node::tag::node256, other) {}

void add_child(node** ref, unsigned char c, node* child);
void rem_child(node** ref, unsigned char c);
Expand All @@ -366,8 +357,7 @@ private:
typename node::tag type;
value_type kv;

leaf(value_type arg_kv) : type(node::tag::leaf), kv(std::move(arg_kv)) {
}
leaf(value_type arg_kv) : type(node::tag::leaf), kv(std::move(arg_kv)) {}

const key_type& key() const {
return kv.first;
Expand Down Expand Up @@ -699,8 +689,8 @@ radix_tree<T, N>::find_child(node* n, unsigned char c) {
}

template <typename T, std::size_t N>
size_t
radix_tree<T, N>::prefix_shared(node* n, const key_type& key, int depth) {
size_t radix_tree<T, N>::prefix_shared(node* n, const key_type& key,
int depth) {
auto key_data = as_key_data(key);
// Null-terminator is part of the key.
auto max_cmp = std::min(std::min(N, static_cast<size_t>(n->partial_len)),
Expand All @@ -715,8 +705,8 @@ radix_tree<T, N>::prefix_shared(node* n, const key_type& key, int depth) {
}

template <typename T, std::size_t N>
size_t
radix_tree<T, N>::prefix_mismatch(node* n, const key_type& key, int depth) {
size_t radix_tree<T, N>::prefix_mismatch(node* n, const key_type& key,
int depth) {
auto key_data = as_key_data(key);
// Null-terminator is part of the key.
auto max_cmp = std::min(std::min(N, static_cast<size_t>(n->partial_len)),
Expand Down Expand Up @@ -1255,8 +1245,7 @@ void radix_tree<T, N>::node256::rem_child(node** ref, unsigned char c) {

template <typename T, std::size_t N>
radix_tree<T, N>::iterator::iterator(node* arg_root, node* starting_point)
: root(arg_root), node_ptr(starting_point), ready_to_iterate(false) {
}
: root(arg_root), node_ptr(starting_point), ready_to_iterate(false) {}

template <typename T, std::size_t N>
typename radix_tree<T, N>::iterator::reference
Expand Down
3 changes: 1 addition & 2 deletions include/broker/detail/subscription.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public:

/// Construct from given actor and topic set.
subscriber(caf::actor a, topic_set ts)
: who(std::move(a)), subscriptions(std::move(ts)) {
}
: who(std::move(a)), subscriptions(std::move(ts)) {}

caf::actor who = caf::invalid_actor;
topic_set subscriptions;
Expand Down
8 changes: 4 additions & 4 deletions include/broker/detail/type_traits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct are_same<A, B> {

template <class A, class B, class C, class... Ts>
struct are_same<A, B, C, Ts...> {
static constexpr bool value
= std::is_same_v<A, B> && are_same<B, C, Ts...>::value;
static constexpr bool value =
std::is_same_v<A, B> && are_same<B, C, Ts...>::value;
};

template <class... Ts>
Expand Down Expand Up @@ -65,8 +65,8 @@ auto has_apply_operator_test(U*) -> decltype(&U::operator(), std::true_type());
auto has_apply_operator_test(...) -> std::false_type;

template <class T>
inline constexpr bool has_apply_operator
= decltype(has_apply_operator_test(std::declval<T*>()))::value;
inline constexpr bool has_apply_operator =
decltype(has_apply_operator_test(std::declval<T*>()))::value;

template <class F>
struct normalized_signature;
Expand Down
Loading

0 comments on commit 1808f44

Please sign in to comment.