Skip to content

Commit 9ae9c36

Browse files
committed
Sema: Remove unnecessary overload of computeTupleShuffle()
1 parent f81a0d9 commit 9ae9c36

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6083,27 +6083,19 @@ class HandlePlaceholderType {
60836083
/// Compute the shuffle required to map from a given tuple type to
60846084
/// another tuple type.
60856085
///
6086-
/// \param fromTuple The tuple type we're converting from, as represented by its
6087-
/// TupleTypeElt members.
6086+
/// \param fromTuple The tuple type we're converting from.
60886087
///
6089-
/// \param toTuple The tuple type we're converting to, as represented by its
6090-
/// TupleTypeElt members.
6088+
/// \param toTuple The tuple type we're converting to.
60916089
///
60926090
/// \param sources Will be populated with information about the source of each
60936091
/// of the elements for the result tuple. The indices into this array are the
60946092
/// indices of the tuple type we're converting to, while the values are
60956093
/// an index into the source tuple.
60966094
///
60976095
/// \returns true if no tuple conversion is possible, false otherwise.
6098-
bool computeTupleShuffle(ArrayRef<TupleTypeElt> fromTuple,
6099-
ArrayRef<TupleTypeElt> toTuple,
6096+
bool computeTupleShuffle(TupleType *fromTuple,
6097+
TupleType *toTuple,
61006098
SmallVectorImpl<unsigned> &sources);
6101-
static inline bool computeTupleShuffle(TupleType *fromTuple,
6102-
TupleType *toTuple,
6103-
SmallVectorImpl<unsigned> &sources){
6104-
return computeTupleShuffle(fromTuple->getElements(), toTuple->getElements(),
6105-
sources);
6106-
}
61076099

61086100
/// Class used as the base for listeners to the \c matchCallArguments process.
61096101
///

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,21 @@ void *operator new(size_t bytes, ConstraintSystem& cs,
159159
return cs.getAllocator().Allocate(bytes, alignment);
160160
}
161161

162-
bool constraints::computeTupleShuffle(ArrayRef<TupleTypeElt> fromTuple,
163-
ArrayRef<TupleTypeElt> toTuple,
162+
bool constraints::computeTupleShuffle(TupleType *fromTuple,
163+
TupleType *toTuple,
164164
SmallVectorImpl<unsigned> &sources) {
165165
const unsigned unassigned = -1;
166166

167-
SmallVector<bool, 4> consumed(fromTuple.size(), false);
167+
auto fromElts = fromTuple->getElements();
168+
auto toElts = toTuple->getElements();
169+
170+
SmallVector<bool, 4> consumed(fromElts.size(), false);
168171
sources.clear();
169-
sources.assign(toTuple.size(), unassigned);
172+
sources.assign(toElts.size(), unassigned);
170173

171174
// Match up any named elements.
172-
for (unsigned i = 0, n = toTuple.size(); i != n; ++i) {
173-
const auto &toElt = toTuple[i];
175+
for (unsigned i = 0, n = toElts.size(); i != n; ++i) {
176+
const auto &toElt = toElts[i];
174177

175178
// Skip unnamed elements.
176179
if (!toElt.hasName())
@@ -180,7 +183,7 @@ bool constraints::computeTupleShuffle(ArrayRef<TupleTypeElt> fromTuple,
180183
int matched = -1;
181184
{
182185
int index = 0;
183-
for (auto field : fromTuple) {
186+
for (auto field : fromElts) {
184187
if (field.getName() == toElt.getName() && !consumed[index]) {
185188
matched = index;
186189
break;
@@ -197,14 +200,14 @@ bool constraints::computeTupleShuffle(ArrayRef<TupleTypeElt> fromTuple,
197200
}
198201

199202
// Resolve any unmatched elements.
200-
unsigned fromNext = 0, fromLast = fromTuple.size();
203+
unsigned fromNext = 0, fromLast = fromElts.size();
201204
auto skipToNextAvailableInput = [&] {
202205
while (fromNext != fromLast && consumed[fromNext])
203206
++fromNext;
204207
};
205208
skipToNextAvailableInput();
206209

207-
for (unsigned i = 0, n = toTuple.size(); i != n; ++i) {
210+
for (unsigned i = 0, n = toElts.size(); i != n; ++i) {
208211
// Check whether we already found a value for this element.
209212
if (sources[i] != unassigned)
210213
continue;
@@ -215,11 +218,11 @@ bool constraints::computeTupleShuffle(ArrayRef<TupleTypeElt> fromTuple,
215218
}
216219

217220
// Otherwise, assign this input to the next output element.
218-
const auto &elt2 = toTuple[i];
221+
const auto &elt2 = toElts[i];
219222

220223
// Fail if the input element is named and we're trying to match it with
221224
// something with a different label.
222-
if (fromTuple[fromNext].hasName() && elt2.hasName())
225+
if (fromElts[fromNext].hasName() && elt2.hasName())
223226
return true;
224227

225228
sources[i] = fromNext;

0 commit comments

Comments
 (0)