-
Notifications
You must be signed in to change notification settings - Fork 61
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
Polish CodeQL and do some chores #2255
Changes from 1 commit
e6d0e14
61fff65
9f5d14e
8b0c6f9
a170cfa
da0d437
d48759d
9d25ce6
883065e
2e2f329
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,25 +47,24 @@ struct dry_run_context_impl { | |
void remote_ctrl_send_done() const {} | ||
gathered_vector<cell_gid_type> | ||
gather_gids(const std::vector<cell_gid_type>& local_gids) const { | ||
using count_type = typename gathered_vector<cell_gid_type>::count_type; | ||
|
||
count_type local_size = local_gids.size(); | ||
size_t local_size = local_gids.size(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and all other instance in that file. |
||
|
||
std::vector<cell_gid_type> gathered_gids; | ||
gathered_gids.reserve(size_t{local_size}*num_ranks_); | ||
gathered_gids.reserve(local_size*num_ranks_); | ||
|
||
for (count_type i = 0; i < num_ranks_; i++) { | ||
for (size_t i = 0; i < num_ranks_; i++) { | ||
util::append(gathered_gids, local_gids); | ||
} | ||
|
||
for (count_type i = 0; i < num_ranks_; i++) { | ||
for (count_type j = i*local_size; j < (i+1)*local_size; j++){ | ||
for (size_t i = 0; i < num_ranks_; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 more |
||
for (size_t j = i*local_size; j < (i+1)*local_size; j++){ | ||
gathered_gids[j] += num_cells_per_tile_*i; | ||
} | ||
} | ||
|
||
using count_type = typename gathered_vector<cell_gid_type>::count_type; | ||
std::vector<count_type> partition; | ||
for (count_type i = 0; i <= num_ranks_; i++) { | ||
for (size_t i = 0; i <= num_ranks_; i++) { | ||
partition.push_back(static_cast<count_type>(i*local_size)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no point doing everything in |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,10 +75,14 @@ | |
|
||
static void apply_indent_prefix(std::ios& s, int index) { | ||
if (auto pbuf = dynamic_cast<prefixbuf*>(s.rdbuf())) { | ||
indent_stack* stack_ptr = static_cast<indent_stack*>(s.pword(index)); | ||
size_t tabs = (!stack_ptr || stack_ptr->empty())? 0 : stack_ptr->top(); | ||
size_t tabwidth = s.iword(index); | ||
pbuf->prefix = std::string(tabs*tabwidth, ' '); | ||
if (auto ptr = static_cast<indent_stack*>(s.pword(index)); | ||
ptr && !ptr->empty()) { | ||
unsigned n_tab = ptr->top(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Argh! This is terribly misleading formatting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I knew you were going to love it. Isn't it beautiful how the second line of the condition and the first line of the body line up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has a certain horrible charm to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed it. |
||
unsigned width = s.iword(index); | ||
pbuf->prefix = std::string(n_tab*width, ' '); | ||
|
||
} else { | ||
pbuf->prefix = std::string(); | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,8 +377,8 @@ class sde_recipe: public simple_recipe_base { | |
// generic advance method used for all pertinent mechanisms | ||
// first argument indicates the number of random variables | ||
void advance_common(unsigned int n_rv, arb_mechanism_ppack* pp) { | ||
const auto width = pp->width; | ||
arb_value_type* ptr = archive_ptr->claim(std::size_t{width} * n_rv); | ||
auto width = static_cast<size_t>(pp->width); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just |
||
arb_value_type* ptr = archive_ptr->claim(width*n_rv); | ||
|
||
for (arb_size_type j=0; j<n_rv; ++j) { | ||
for (arb_size_type i=0; i<width; ++i) { | ||
ptr[j*width+i] = pp->random_numbers[j][i]; | ||
|
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.
Are these changes to make CodeQL happy, or just for readability?
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.
Readability. I can get behind
a*b + c
for similarities with mathematical notation, but=
,==
, and especially-
tend to merge visually into one token. Or: Too similar tosnake_case
for my liking.As much of the code, especially newer parts is in this style, I tend to adjust these expression in passing when editing files. Same for removing redundant headers, which my IDE picks up on these days.