-
Notifications
You must be signed in to change notification settings - Fork 221
experimental: use clang-format for buffer and graph #1400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
experimental: use clang-format for buffer and graph #1400
Conversation
namespace boost { namespace geometry | ||
namespace boost | ||
{ | ||
namespace geometry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find a rule which doesn't affect this style for namespace.
Maybe we can live with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the more detailled Brace rules as in #1400 (comment) , I can get namespace boost { namespace geometry {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better for sure! Thanks! Applied!
|
||
using turn_vector_type = std::vector<buffer_turn_info_type>; | ||
|
||
using piece_border_type = piece_border<Ring, point_type> ; | ||
using piece_border_type = piece_border<Ring, point_type>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It nicely catches these kind of small errors.
include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp
Outdated
Show resolved
Hide resolved
typename Turns, | ||
typename Pieces, | ||
typename DistanceStrategy, | ||
typename UmbrellaStrategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also different than what we had. But it is (as far as I can see) the variant closest possible.
auto const source_turn_indices | ||
= get_turn_indices_by_node_id(turns, clusters, source_node_id, allow_closed); | ||
auto const target_turn_indices | ||
= get_turn_indices_by_node_id(turns, clusters, target_node_id, allow_closed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catches of wrong const
placements, from me recently...
<< std::endl; | ||
std::cout << "quadratic: " << source_node_id << " -> " << target_node_id << " sizes " | ||
<< source_turn_indices.size() << " x " << target_turn_indices.size() << " = " | ||
<< result.size() << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal IMO but I don't think we can get this completely satisfactory
struct is_better_collinear_target {}; | ||
struct is_better_collinear_target | ||
{ | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somehow split (though I have AllowShortBlocksOnASingleLine
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the more detailled Brace rules as in #1400 (comment) , I can get
template <operation_type Operation>
struct is_better_collinear_target
{};
include/boost/geometry/algorithms/detail/overlay/graph/select_edge.hpp
Outdated
Show resolved
Hide resolved
bool const better = is_better_collinear_for_union( | ||
op0, op1, edges.front().toi, edges.back().toi); | ||
bool const better | ||
= is_better_collinear_for_union(op0, op1, edges.front().toi, edges.back().toi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nicer IMO
return side == -1 ? geometry::strategy::buffer::join_convex | ||
: side == 1 ? geometry::strategy::buffer::join_concave | ||
: same_direction(p0, p1, p2) ? geometry::strategy::buffer::join_continue | ||
: geometry::strategy::buffer::join_spike; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not too bad, actually better than I've ever seen from clang-format
first_p1, | ||
first_p2, | ||
last_p1, | ||
last_p2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really nice... but still acceptable probably
This looks very convenient and I think having a style that can be programmatically enforced but is slightly different from before is better than having a style that is more difficult to ensure consistency for, I'm definitely in favour of this change. The behaviour for namespaces and empty structs can maybe be made closer to the original by breaking up the Allman style into custom rules to partially address #1400 (comment) and #1400 (comment) like this: -BreakBeforeBraces: Allman
+BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: false
+ AfterStruct: true
+ AfterUnion: true
+ AfterExternBlock: true
+ BeforeCatch: true
+ BeforeElse: true
+ BeforeLambdaBody: true
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+ IndentBraces: false The following may also be of interest, if this is to be mass-applied, to somewhat preserve the ability to use git blame to understand why some particular line was changed, it requires logging the commit in a file called .git-blame-ignore-revs at root. |
Applied on two folders only!
This is experimental and verifies how
clang-format
could be used for our code base,using a style that is most close to what we (in general) use.
I used
clang-format-15
.Other Boost libraries
clang-format
is used by a few other boost libraries. I tried some of these configurations, but it was not satisfactory to my taste.Here an indication (on a branch of somewhere last year), with sizes in bytes: