Runtime: use SmallVector instead of std::vector to avoid memory allocations in most cases.

This dramatically reduces the number of needed malloc calls.
Unfortunately I had to add the implementation of SmallVectorBase::grow_pod to the runtime, as we don't link LLVM. This is a bad hack, but better than re-inventing a new SmallVector implementation.

SR-10028
rdar://problem/48575729
This commit is contained in:
Erik Eckstein
2019-03-04 14:26:40 -08:00
parent 9050be62de
commit 3bd7f027f8
8 changed files with 78 additions and 38 deletions

View File

@@ -162,7 +162,7 @@ template<>
const WitnessTable *
ProtocolConformanceDescriptor::getWitnessTable(const Metadata *type) const {
// If needed, check the conditional requirements.
std::vector<const void *> conditionalArgs;
SmallVector<const void *, 8> conditionalArgs;
if (hasConditionalRequirements()) {
SubstGenericParametersFromMetadata substitutions(type);
bool failed =
@@ -626,7 +626,7 @@ swift::_searchConformancesByMangledTypeName(Demangle::NodePointer node) {
bool swift::_checkGenericRequirements(
llvm::ArrayRef<GenericRequirementDescriptor> requirements,
std::vector<const void *> &extraArguments,
SmallVectorImpl<const void *> &extraArguments,
SubstGenericParameterFn substGenericParam,
SubstDependentWitnessTableFn substWitnessTable) {
for (const auto &req : requirements) {