mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Prefer anonymous functions instead of member pointers here.
This is blocking proper const-correctness for value witness types.
This commit is contained in:
@@ -613,22 +613,19 @@ static void tuple_destroyArray(OpaqueValue *array, size_t n,
|
||||
|
||||
// The operation doesn't have to be initializeWithCopy, but they all
|
||||
// have basically the same type.
|
||||
typedef value_witness_types::initializeWithCopy
|
||||
ValueWitnessTable::*forEachOperation;
|
||||
typedef value_witness_types::initializeWithCopy forEachOperation;
|
||||
|
||||
/// Perform an operation for each field of two tuples.
|
||||
static OpaqueValue *tuple_forEachField(OpaqueValue *destTuple,
|
||||
OpaqueValue *srcTuple,
|
||||
const Metadata *_metatype,
|
||||
forEachOperation member) {
|
||||
forEachOperation operation) {
|
||||
auto &metatype = *(const TupleTypeMetadata*) _metatype;
|
||||
for (size_t i = 0, e = metatype.NumElements; i != e; ++i) {
|
||||
auto &eltInfo = metatype.getElement(i);
|
||||
auto eltValueWitnesses = eltInfo.Type->getValueWitnesses();
|
||||
|
||||
OpaqueValue *destElt = eltInfo.findIn(destTuple);
|
||||
OpaqueValue *srcElt = eltInfo.findIn(srcTuple);
|
||||
(eltValueWitnesses->*member)(destElt, srcElt, eltInfo.Type);
|
||||
operation(destElt, srcElt, eltInfo.Type);
|
||||
}
|
||||
|
||||
return destTuple;
|
||||
@@ -671,7 +668,9 @@ static OpaqueValue *tuple_initializeWithCopy(OpaqueValue *dest,
|
||||
|
||||
if (IsPOD) return tuple_memcpy(dest, src, metatype);
|
||||
return tuple_forEachField(dest, src, metatype,
|
||||
&ValueWitnessTable::initializeWithCopy);
|
||||
[](OpaqueValue *dest, OpaqueValue *src, const Metadata *eltType) {
|
||||
return eltType->vw_initializeWithCopy(dest, src);
|
||||
});
|
||||
}
|
||||
|
||||
/// Generic tuple value witness for 'initializeArrayWithCopy'.
|
||||
@@ -709,7 +708,9 @@ static OpaqueValue *tuple_initializeWithTake(OpaqueValue *dest,
|
||||
|
||||
if (IsPOD) return tuple_memcpy(dest, src, metatype);
|
||||
return tuple_forEachField(dest, src, metatype,
|
||||
&ValueWitnessTable::initializeWithTake);
|
||||
[](OpaqueValue *dest, OpaqueValue *src, const Metadata *eltType) {
|
||||
return eltType->vw_initializeWithTake(dest, src);
|
||||
});
|
||||
}
|
||||
|
||||
/// Generic tuple value witness for 'initializeArrayWithTakeFrontToBack'.
|
||||
@@ -774,7 +775,9 @@ static OpaqueValue *tuple_assignWithCopy(OpaqueValue *dest,
|
||||
|
||||
if (IsPOD) return tuple_memcpy(dest, src, metatype);
|
||||
return tuple_forEachField(dest, src, metatype,
|
||||
&ValueWitnessTable::assignWithCopy);
|
||||
[](OpaqueValue *dest, OpaqueValue *src, const Metadata *eltType) {
|
||||
return eltType->vw_assignWithCopy(dest, src);
|
||||
});
|
||||
}
|
||||
|
||||
/// Generic tuple value witness for 'assignWithTake'.
|
||||
@@ -784,7 +787,9 @@ static OpaqueValue *tuple_assignWithTake(OpaqueValue *dest,
|
||||
const Metadata *metatype) {
|
||||
if (IsPOD) return tuple_memcpy(dest, src, metatype);
|
||||
return tuple_forEachField(dest, src, metatype,
|
||||
&ValueWitnessTable::assignWithTake);
|
||||
[](OpaqueValue *dest, OpaqueValue *src, const Metadata *eltType) {
|
||||
return eltType->vw_assignWithTake(dest, src);
|
||||
});
|
||||
}
|
||||
|
||||
/// Generic tuple value witness for 'initializeBufferWithCopyOfBuffer'.
|
||||
|
||||
Reference in New Issue
Block a user