Skip to content

Commit e171ba7

Browse files
committed
Using const iterator first
1 parent ac56d23 commit e171ba7

29 files changed

+126
-126
lines changed

velox/core/Expressions.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ class CallTypedExpr : public ITypedExpr {
247247
return false;
248248
}
249249
return std::equal(
250-
this->inputs().begin(),
251-
this->inputs().end(),
252-
other.inputs().begin(),
253-
other.inputs().end(),
250+
this->inputs().cbegin(),
251+
this->inputs().cend(),
252+
other.inputs().cbegin(),
253+
other.inputs().cend(),
254254
[](const auto& p1, const auto& p2) { return *p1 == *p2; });
255255
}
256256

@@ -316,10 +316,10 @@ class FieldAccessTypedExpr : public ITypedExpr {
316316
return false;
317317
}
318318
return std::equal(
319-
this->inputs().begin(),
320-
this->inputs().end(),
321-
other.inputs().begin(),
322-
other.inputs().end(),
319+
this->inputs().cbegin(),
320+
this->inputs().cend(),
321+
other.inputs().cbegin(),
322+
other.inputs().cend(),
323323
[](const auto& p1, const auto& p2) { return *p1 == *p2; });
324324
}
325325

@@ -396,10 +396,10 @@ class DereferenceTypedExpr : public ITypedExpr {
396396
return false;
397397
}
398398
return std::equal(
399-
this->inputs().begin(),
400-
this->inputs().end(),
401-
other.inputs().begin(),
402-
other.inputs().end(),
399+
this->inputs().cbegin(),
400+
this->inputs().cend(),
401+
other.inputs().cbegin(),
402+
other.inputs().cend(),
403403
[](const auto& p1, const auto& p2) { return *p1 == *p2; });
404404
}
405405

@@ -451,10 +451,10 @@ class ConcatTypedExpr : public ITypedExpr {
451451
return false;
452452
}
453453
return std::equal(
454-
this->inputs().begin(),
455-
this->inputs().end(),
456-
other.inputs().begin(),
457-
other.inputs().end(),
454+
this->inputs().cbegin(),
455+
this->inputs().cend(),
456+
other.inputs().cbegin(),
457+
other.inputs().cend(),
458458
[](const auto& p1, const auto& p2) { return *p1 == *p2; });
459459
}
460460

velox/core/PlanNode.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ std::vector<std::string> allNames(
11381138
const std::vector<std::string>& names,
11391139
const std::vector<std::string>& moreNames) {
11401140
auto result = names;
1141-
result.insert(result.end(), moreNames.begin(), moreNames.end());
1141+
result.insert(result.cend(), moreNames.cbegin(), moreNames.cend());
11421142
return result;
11431143
}
11441144

@@ -1150,7 +1150,7 @@ std::vector<TypedExprPtr> flattenExprs(
11501150
const PlanNodePtr& input) {
11511151
std::vector<TypedExprPtr> result;
11521152
for (auto& group : exprs) {
1153-
result.insert(result.end(), group.begin(), group.end());
1153+
result.insert(result.cend(), group.cbegin(), group.cend());
11541154
}
11551155

11561156
const auto& sourceType = input->outputType();
@@ -2502,7 +2502,7 @@ const char* TopNRowNumberNode::rankFunctionName(
25022502
static const auto kFunctionNames = rankFunctionNames();
25032503
auto it = kFunctionNames.find(function);
25042504
VELOX_CHECK(
2505-
it != kFunctionNames.end(),
2505+
it != kFunctionNames.cend(),
25062506
"Invalid rank function {}",
25072507
static_cast<int>(function));
25082508
return it->second.c_str();
@@ -2513,7 +2513,7 @@ TopNRowNumberNode::RankFunction TopNRowNumberNode::rankFunctionFromName(
25132513
std::string_view name) {
25142514
static const auto kFunctionNames = invertMap(rankFunctionNames());
25152515
auto it = kFunctionNames.find(name.data());
2516-
VELOX_CHECK(it != kFunctionNames.end(), "Invalid rank function {}", name);
2516+
VELOX_CHECK(it != kFunctionNames.cend(), "Invalid rank function {}", name);
25172517
return it->second;
25182518
}
25192519

velox/core/PlanNode.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,10 @@ class AggregationNode : public PlanNode {
13011301
bool isPreGrouped() const {
13021302
return !preGroupedKeys_.empty() &&
13031303
std::equal(
1304-
preGroupedKeys_.begin(),
1305-
preGroupedKeys_.end(),
1306-
groupingKeys_.begin(),
1307-
groupingKeys_.end(),
1304+
preGroupedKeys_.cbegin(),
1305+
preGroupedKeys_.cend(),
1306+
groupingKeys_.cbegin(),
1307+
groupingKeys_.cend(),
13081308
[](const FieldAccessTypedExprPtr& x,
13091309
const FieldAccessTypedExprPtr& y) -> bool {
13101310
return (*x == *y);

velox/dwio/common/DataBufferHolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void DataBufferHolder::take(const std::vector<std::string_view>& buffers) {
3838
auto* data = buf.data();
3939
for (auto& buffer : buffers) {
4040
const auto size = buffer.size();
41-
::memcpy(data, buffer.begin(), size);
41+
::memcpy(data, buffer.cbegin(), size);
4242
data += size;
4343
}
4444
// If possibly, write content of the data to output immediately. Otherwise,

velox/dwio/common/DirectBufferedInput.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ std::shared_ptr<DirectCoalescedLoad> DirectBufferedInput::coalescedLoad(
235235
return streamToCoalescedLoad_.withWLock(
236236
[&](auto& loads) -> std::shared_ptr<DirectCoalescedLoad> {
237237
auto it = loads.find(stream);
238-
if (it == loads.end()) {
238+
if (it == loads.cend()) {
239239
return nullptr;
240240
}
241241
auto load = std::move(it->second);
@@ -340,10 +340,10 @@ int32_t DirectCoalescedLoad::getData(
340340
memory::Allocation& data,
341341
std::string& tinyData) {
342342
auto it = std::lower_bound(
343-
requests_.begin(), requests_.end(), offset, [](auto& x, auto offset) {
343+
requests_.cbegin(), requests_.cend(), offset, [](auto& x, auto offset) {
344344
return x.region.offset < offset;
345345
});
346-
if (it == requests_.end() || it->region.offset != offset) {
346+
if (it == requests_.cend() || it->region.offset != offset) {
347347
return 0;
348348
}
349349
data = std::move(it->data);

velox/dwio/common/DirectBufferedInput.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class DirectCoalescedLoad : public cache::CoalescedLoad {
7171
pool_(pool) {
7272
VELOX_DCHECK_NOT_NULL(pool_);
7373
VELOX_DCHECK(
74-
std::is_sorted(requests.begin(), requests.end(), [](auto* x, auto* y) {
74+
std::is_sorted(requests.cbegin(), requests.cend(), [](auto* x, auto* y) {
7575
return x->region.offset < y->region.offset;
7676
}));
7777
requests_.reserve(requests.size());

velox/dwio/common/FlatMapHelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ KeyPredicate<T> prepareKeyPredicate(std::string_view expression) {
236236
// You cannot mix allow key and reject key.
237237
VELOX_CHECK(
238238
modes.empty() ||
239-
std::all_of(modes.begin(), modes.end(), [&modes](const auto& v) {
239+
std::all_of(modes.cbegin(), modes.cend(), [&modes](const auto& v) {
240240
return v == modes.front();
241241
}));
242242

243243
auto mode = modes.empty() ? KeyProjectionMode::ALLOW : modes.front();
244244

245245
return KeyPredicate<T>(
246-
mode, typename KeyPredicate<T>::Lookup(keys.begin(), keys.end()));
246+
mode, typename KeyPredicate<T>::Lookup(keys.cbegin(), keys.cend()));
247247
}
248248

249249
} // namespace facebook::velox::dwio::common::flatmap

velox/dwio/common/Options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ class RowReaderOptions {
312312
flatmapNodeIdsAsStruct) {
313313
VELOX_CHECK(
314314
std::all_of(
315-
flatmapNodeIdsAsStruct.begin(),
316-
flatmapNodeIdsAsStruct.end(),
315+
flatmapNodeIdsAsStruct.cbegin(),
316+
flatmapNodeIdsAsStruct.cend(),
317317
[](const auto& kv) { return !kv.second.empty(); }),
318318
"To use struct encoding for flatmap, keys to project must be specified");
319319
flatmapNodeIdAsStruct_ = std::move(flatmapNodeIdsAsStruct);

velox/dwio/common/ScanSpec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ uint64_t ScanSpec::newRead() {
104104
if (numReads_ == 0 ||
105105
(!disableStatsBasedFilterReorder_ &&
106106
!std::is_sorted(
107-
children_.begin(),
108-
children_.end(),
107+
children_.cbegin(),
108+
children_.cend(),
109109
[this](
110110
const std::shared_ptr<ScanSpec>& left,
111111
const std::shared_ptr<ScanSpec>& right) {

velox/dwio/common/StreamUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ inline void readContiguous(
144144

145145
// Returns the number of elements in rows that are < limit.
146146
inline int32_t numBelow(folly::Range<const int32_t*> rows, int32_t limit) {
147-
return std::lower_bound(rows.begin(), rows.end(), limit) - rows.begin();
147+
return std::lower_bound(rows.cbegin(), rows.cend(), limit) - rows.cbegin();
148148
}
149149

150150
template <typename T, typename SingleValue, typename SparseRange>

0 commit comments

Comments
 (0)