Skip to content

Commit 0ff69d4

Browse files
authored
Prefer Pre-Inc to Post-Inc.
Change all post-increments to pre-increments. For example consider the following: ``` class Integer { public: // Sample implementation of pre-incrementing. Integer & operator++() { myInt += 1; return *this; } // Sample implementation of post-incrementing. const Integer operator++(int) { Integer temporary = *this; ++*this; return temporary; } private: int myInt; }; ``` The additional copy (temporary) in post-incrementing step is unnecessary.
1 parent 065a25f commit 0ff69d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/SILOptimizer/Analysis/AccessSummaryAnalysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void AccessSummaryAnalysis::processFunction(FunctionInfo *info,
3232
FunctionSummary &functionSummary = info->getSummary();
3333
ArgumentSummary &argSummary =
3434
functionSummary.getAccessForArgument(index);
35-
index++;
35+
++index;
3636

3737
auto *functionArg = cast<SILFunctionArgument>(arg);
3838
// Only summarize @inout_aliasable arguments.
@@ -423,7 +423,7 @@ AccessSummaryAnalysis::ArgumentSummary::getDescription(SILType BaseType,
423423
os << ", ";
424424
}
425425
os << subAccess.getDescription(BaseType, M);
426-
index++;
426+
++index;
427427
}
428428
os << "]";
429429

@@ -594,7 +594,7 @@ static unsigned subPathLength(const IndexTrieNode *subPath) {
594594

595595
const IndexTrieNode *iter = subPath;
596596
while (iter) {
597-
length++;
597+
++length;
598598
iter = iter->getParent();
599599
}
600600

@@ -628,7 +628,7 @@ void AccessSummaryAnalysis::FunctionSummary::print(raw_ostream &os,
628628
unsigned argCount = getArgumentCount();
629629
os << "(";
630630

631-
for (unsigned i = 0; i < argCount; i++) {
631+
for (unsigned i = 0; i < argCount; ++i) {
632632
if (i > 0) {
633633
os << ", ";
634634
}

0 commit comments

Comments
 (0)