Skip to content

Commit

Permalink
Fixed some of the const correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmoein committed Jul 3, 2023
1 parent 752fcbd commit 16c6b85
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 67 deletions.
44 changes: 22 additions & 22 deletions include/DataFrame/Internals/DataFrame.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ DataFrame<I, H>::shuffle(const StlVecType<const char *> &col_names,
shuffle_functor_<Ts ...> functor;
const SpinGuard guard(lock_);

for (auto name_citer : col_names) [[likely]] {
for (const auto &name_citer : col_names) [[likely]] {
const auto citer = column_tb_.find (name_citer);

if (citer == column_tb_.end()) [[unlikely]] {
Expand Down Expand Up @@ -338,8 +338,8 @@ fill_missing_linter_(ColumnVecType<T> &vec,
if (vec_size < 3) return;

int count = 0;
T *y1 = &(vec[0]);
T *y2 = &(vec[2]);
const T *y1 = &(vec[0]);
const T *y2 = &(vec[2]);
const IndexType *x = &(index[1]);
const IndexType *x1 = &(index[0]);
const IndexType *x2 = &(index[2]);
Expand Down Expand Up @@ -398,7 +398,7 @@ fill_missing(const StlVecType<const char *> &col_names,
int limit) {

const size_type count = col_names.size();
StlVecType<std::future<void>> futures(get_thread_level());
StlVecType<std::future<void>> futures(get_thread_level());
size_type thread_count = 0;

for (size_type i = 0; i < count; ++i) {
Expand Down Expand Up @@ -779,9 +779,9 @@ sort(const char *name1, sort_spec dir1, const char *name2, sort_spec dir2,

make_consistent<Ts ...>();

ColumnVecType<T1> *vec1 { nullptr};
ColumnVecType<T2> *vec2 { nullptr};
const SpinGuard guard (lock_);
const ColumnVecType<T1> *vec1 { nullptr};
const ColumnVecType<T2> *vec2 { nullptr};
const SpinGuard guard (lock_);

if (! ::strcmp(name1, DF_INDEX_COL_NAME))
vec1 = reinterpret_cast<ColumnVecType<T1> *>(&indices_);
Expand Down Expand Up @@ -1002,10 +1002,10 @@ sort(const char *name1, sort_spec dir1,

make_consistent<Ts ...>();

ColumnVecType<T1> *vec1 { nullptr};
ColumnVecType<T2> *vec2 { nullptr};
ColumnVecType<T3> *vec3 { nullptr};
const SpinGuard guard (lock_);
const ColumnVecType<T1> *vec1 { nullptr};
const ColumnVecType<T2> *vec2 { nullptr};
const ColumnVecType<T3> *vec3 { nullptr};
const SpinGuard guard (lock_);

if (! ::strcmp(name1, DF_INDEX_COL_NAME))
vec1 = reinterpret_cast<ColumnVecType<T1> *>(&indices_);
Expand Down Expand Up @@ -1102,11 +1102,11 @@ sort(const char *name1, sort_spec dir1,

make_consistent<Ts ...>();

ColumnVecType<T1> *vec1 { nullptr};
ColumnVecType<T2> *vec2 { nullptr};
ColumnVecType<T3> *vec3 { nullptr};
ColumnVecType<T4> *vec4 { nullptr};
const SpinGuard guard (lock_);
const ColumnVecType<T1> *vec1 { nullptr};
const ColumnVecType<T2> *vec2 { nullptr};
const ColumnVecType<T3> *vec3 { nullptr};
const ColumnVecType<T4> *vec4 { nullptr};
const SpinGuard guard (lock_);

if (! ::strcmp(name1, DF_INDEX_COL_NAME))
vec1 = reinterpret_cast<ColumnVecType<T1> *>(&indices_);
Expand Down Expand Up @@ -1235,12 +1235,12 @@ sort(const char *name1, sort_spec dir1,

make_consistent<Ts ...>();

ColumnVecType<T1> *vec1 { nullptr};
ColumnVecType<T2> *vec2 { nullptr};
ColumnVecType<T3> *vec3 { nullptr};
ColumnVecType<T4> *vec4 { nullptr};
ColumnVecType<T5> *vec5 { nullptr};
const SpinGuard guard (lock_);
const ColumnVecType<T1> *vec1 { nullptr};
const ColumnVecType<T2> *vec2 { nullptr};
const ColumnVecType<T3> *vec3 { nullptr};
const ColumnVecType<T4> *vec4 { nullptr};
const ColumnVecType<T5> *vec5 { nullptr};
const SpinGuard guard (lock_);

if (! ::strcmp(name1, DF_INDEX_COL_NAME))
vec1 = reinterpret_cast<ColumnVecType<T1> *>(&indices_);
Expand Down
58 changes: 29 additions & 29 deletions include/DataFrame/Internals/DataFrame_get.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ template<typename T>
typename DataFrame<I, H>::template ColumnVecType<T> &
DataFrame<I, H>::get_column (const char *name, bool do_lock) {

auto iter = column_tb_.find (name);
const auto iter = column_tb_.find (name);

if (iter == column_tb_.end()) [[unlikely]] {
char buffer [512];
Expand Down Expand Up @@ -156,7 +156,7 @@ DataFrame<I, H>::get_column(size_type index, bool do_lock) {
template<typename I, typename H>
bool DataFrame<I, H>::has_column (const char *name) const {

auto iter = column_tb_.find (name);
const auto iter = column_tb_.find (name);

return (iter != column_tb_.end());
}
Expand Down Expand Up @@ -424,11 +424,11 @@ DataFrame<I, H>::get_view_by_idx (Index2D<IndexType> range) {
static_assert(std::is_base_of<HeteroVector<align_value>, H>::value,
"Only a StdDataFrame can call get_view_by_idx()");

auto lower =
const auto lower =
std::lower_bound (indices_.begin(), indices_.end(), range.begin);
auto upper =
const auto upper =
std::upper_bound (indices_.begin(), indices_.end(), range.end);
View dfv;
View dfv;

if (lower != indices_.end() &&
(upper != indices_.end() || indices_.back() == range.end)) [[likely]] {
Expand Down Expand Up @@ -467,9 +467,9 @@ DataFrame<I, H>::get_view_by_idx (Index2D<IndexType> range) const {
static_assert(std::is_base_of<HeteroVector<align_value>, H>::value,
"Only a StdDataFrame can call get_view_by_idx()");

auto lower =
const auto lower =
std::lower_bound (indices_.begin(), indices_.end(), range.begin);
auto upper =
const auto upper =
std::upper_bound (indices_.begin(), indices_.end(), range.end);
ConstView dfcv;

Expand Down Expand Up @@ -863,7 +863,7 @@ get_data_by_sel (const char *name, F &sel_functor) const {
const ColumnVecType<T> &vec = get_column<T>(name);
const size_type idx_s = indices_.size();
const size_type col_s = vec.size();
StlVecType<size_type> col_indices;
StlVecType<size_type> col_indices;

col_indices.reserve(idx_s / 2);
for (size_type i = 0; i < col_s; ++i)
Expand All @@ -874,7 +874,7 @@ get_data_by_sel (const char *name, F &sel_functor) const {
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -906,7 +906,7 @@ get_view_by_sel (const char *name, F &sel_functor) {
const ColumnVecType<T> &vec = get_column<T>(name);
const size_type idx_s = indices_.size();
const size_type col_s = vec.size();
StlVecType<size_type> col_indices;
StlVecType<size_type> col_indices;

col_indices.reserve(idx_s / 2);
for (size_type i = 0; i < col_s; ++i) [[likely]]
Expand All @@ -919,7 +919,7 @@ get_view_by_sel (const char *name, F &sel_functor) {
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -965,7 +965,7 @@ get_view_by_sel (const char *name, F &sel_functor) const {
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1014,7 +1014,7 @@ get_data_by_sel (const char *name1, const char *name2, F &sel_functor) const {
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1066,7 +1066,7 @@ get_view_by_sel (const char *name1, const char *name2, F &sel_functor) {
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1119,7 +1119,7 @@ get_view_by_sel (const char *name1, const char *name2, F &sel_functor) const {
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1172,7 +1172,7 @@ get_data_by_sel (const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1235,7 +1235,7 @@ get_data_by_sel (F &sel_functor) const {
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1298,7 +1298,7 @@ get_data_by_sel (F &sel_functor, FilterCols && ... filter_cols) const {

// Get the records based on indices
new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1358,7 +1358,7 @@ get_view_by_sel (const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1417,7 +1417,7 @@ get_view_by_sel (const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1477,7 +1477,7 @@ get_data_by_sel(const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1542,7 +1542,7 @@ get_view_by_sel(const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1608,7 +1608,7 @@ get_view_by_sel(const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -1673,7 +1673,7 @@ get_data_by_sel(const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1767,7 +1767,7 @@ get_data_by_sel(const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices) [[likely]]
for (const auto &citer: col_indices) [[likely]]
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1865,7 +1865,7 @@ get_data_by_sel(const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -1967,7 +1967,7 @@ get_data_by_sel(const char *name1,
IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(indices_[citer]);
df.load_index(std::move(new_index));

Expand Down Expand Up @@ -2036,7 +2036,7 @@ get_view_by_sel(const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down Expand Up @@ -2106,7 +2106,7 @@ get_view_by_sel(const char *name1,
typename TheView::IndexVecType new_index;

new_index.reserve(col_indices.size());
for (auto citer: col_indices)
for (const auto &citer: col_indices)
new_index.push_back(&(indices_[citer]));
dfv.indices_ = std::move(new_index);

Expand Down
Loading

0 comments on commit 16c6b85

Please sign in to comment.