mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Runtime] Add layout string handling in swift_arrayAssignWithCopyFrontToBack
By using a specialize function, we only call through the witness table and fetch the layout string once for the whoe buffer, instead of once per element.
This commit is contained in:
@@ -111,6 +111,16 @@ static void array_copy_operation(OpaqueValue *dest, OpaqueValue *src,
|
||||
|
||||
// Call the witness to do the copy.
|
||||
if (copyKind == ArrayCopy::NoAlias || copyKind == ArrayCopy::FrontToBack) {
|
||||
if (self->hasLayoutString() && destOp == ArrayDest::Init &&
|
||||
srcOp == ArraySource::Copy) {
|
||||
return swift_generic_arrayInitWithCopy(dest, src, count, stride, self);
|
||||
}
|
||||
|
||||
if (self->hasLayoutString() && destOp == ArrayDest::Assign &&
|
||||
srcOp == ArraySource::Copy) {
|
||||
return swift_generic_arrayAssignWithCopy(dest, src, count, stride, self);
|
||||
}
|
||||
|
||||
auto copy = get_witness_function<destOp, srcOp>(wtable);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
auto offset = i * stride;
|
||||
@@ -125,10 +135,6 @@ static void array_copy_operation(OpaqueValue *dest, OpaqueValue *src,
|
||||
assert(copyKind == ArrayCopy::BackToFront);
|
||||
assert(count != 0);
|
||||
|
||||
if (self->hasLayoutString() && destOp == ArrayDest::Init && srcOp == ArraySource::Copy) {
|
||||
return swift_generic_arrayInitWithCopy(dest, src, count, stride, self);
|
||||
}
|
||||
|
||||
auto copy = get_witness_function<destOp, srcOp>(wtable);
|
||||
size_t i = count;
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user