Skip to content

Commit 6d9294f

Browse files
committed
Random improvements for ArrayRefView.
1 parent 4fdccaf commit 6d9294f

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

include/swift/Basic/ArrayRefView.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ template <class Orig, class Projected, Projected (&Project)(const Orig &),
2929
class ArrayRefView {
3030
llvm::ArrayRef<Orig> Array;
3131
public:
32+
ArrayRefView() {}
3233
ArrayRefView(llvm::ArrayRef<Orig> array) : Array(array) {}
3334

3435
class iterator {
@@ -111,6 +112,41 @@ class ArrayRefView {
111112
"original array access not enabled for this view");
112113
return Array;
113114
}
115+
116+
friend bool operator==(ArrayRefView lhs, ArrayRefView rhs) {
117+
if (lhs.size() != rhs.size())
118+
return false;
119+
for (auto i : indices(lhs))
120+
if (lhs[i] != rhs[i])
121+
return false;
122+
return true;
123+
}
124+
friend bool operator==(llvm::ArrayRef<Projected> lhs, ArrayRefView rhs) {
125+
if (lhs.size() != rhs.size())
126+
return false;
127+
for (auto i : indices(lhs))
128+
if (lhs[i] != rhs[i])
129+
return false;
130+
return true;
131+
}
132+
friend bool operator==(ArrayRefView lhs, llvm::ArrayRef<Projected> rhs) {
133+
if (lhs.size() != rhs.size())
134+
return false;
135+
for (auto i : indices(lhs))
136+
if (lhs[i] != rhs[i])
137+
return false;
138+
return true;
139+
}
140+
141+
friend bool operator!=(ArrayRefView lhs, ArrayRefView rhs) {
142+
return !(lhs == rhs);
143+
}
144+
friend bool operator!=(llvm::ArrayRef<Projected> lhs, ArrayRefView rhs) {
145+
return !(lhs == rhs);
146+
}
147+
friend bool operator!=(ArrayRefView lhs, llvm::ArrayRef<Projected> rhs) {
148+
return !(lhs == rhs);
149+
}
114150
};
115151

116152
} // end namespace swift

lib/IDE/TypeReconstruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ static void VisitNodeAddressor(
694694
// and they bear no connection to their original variable at the interface
695695
// level
696696
CanFunctionType swift_can_func_type =
697-
CanFunctionType::get(AnyFunctionType::CanParamArrayRef({}),
697+
CanFunctionType::get(AnyFunctionType::CanParamArrayRef(),
698698
ast->TheRawPointerType,
699699
AnyFunctionType::ExtInfo());
700700
result._types.push_back(swift_can_func_type.getPointer());

lib/IRGen/GenMeta.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ namespace {
16841684
// All function types look like () -> ().
16851685
// FIXME: It'd be nice not to have to call through the runtime here.
16861686
return IGF.emitTypeMetadataRef(
1687-
CanFunctionType::get(AnyFunctionType::CanParamArrayRef({ }),
1687+
CanFunctionType::get(AnyFunctionType::CanParamArrayRef(),
16881688
C.TheEmptyTupleType,
16891689
AnyFunctionType::ExtInfo()));
16901690
case SILFunctionType::Representation::Block:
@@ -1866,7 +1866,7 @@ namespace {
18661866
case SILFunctionType::Representation::Thick:
18671867
// All function types look like () -> ().
18681868
return emitFromValueWitnessTable(
1869-
CanFunctionType::get(AnyFunctionType::CanParamArrayRef({}),
1869+
CanFunctionType::get(AnyFunctionType::CanParamArrayRef(),
18701870
C.TheEmptyTupleType,
18711871
AnyFunctionType::ExtInfo()));
18721872
case SILFunctionType::Representation::Block:

lib/IRGen/GenReflection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ void IRGenModule::emitBuiltinReflectionMetadata() {
928928
// extra inhabitants as these. But maybe it's best not to codify
929929
// that in the ABI anyway.
930930
CanType thinFunction = CanFunctionType::get(
931-
AnyFunctionType::CanParamArrayRef({}), Context.TheEmptyTupleType,
931+
AnyFunctionType::CanParamArrayRef(), Context.TheEmptyTupleType,
932932
AnyFunctionType::ExtInfo().withRepresentation(
933933
FunctionTypeRepresentation::Thin));
934934
BuiltinTypes.insert(thinFunction);

0 commit comments

Comments
 (0)