Skip to content

Commit 72fad53

Browse files
committed
Remove allocations due to copying target Triple to local variable.
The isPlatformActive() function wants to choose between Target and TargetVariant. It currently copies in to a local to do this, but Triple contains strings which result in allocations for the copy. This uses a pointer instead, to avoid the allocations entirely, reducing total allocations in the compiler by 5%. rdar://117879768
1 parent b7d8a9b commit 72fad53

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/AST/PlatformKind.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,13 @@ static bool isPlatformActiveForTarget(PlatformKind Platform,
143143

144144
bool swift::isPlatformActive(PlatformKind Platform, const LangOptions &LangOpts,
145145
bool ForTargetVariant) {
146-
llvm::Triple TT = LangOpts.Target;
147-
148146
if (ForTargetVariant) {
149147
assert(LangOpts.TargetVariant && "Must have target variant triple");
150-
TT = *LangOpts.TargetVariant;
148+
return isPlatformActiveForTarget(Platform, *LangOpts.TargetVariant,
149+
LangOpts.EnableAppExtensionRestrictions);
151150
}
152151

153-
return isPlatformActiveForTarget(Platform, TT,
152+
return isPlatformActiveForTarget(Platform, LangOpts.Target,
154153
LangOpts.EnableAppExtensionRestrictions);
155154
}
156155

0 commit comments

Comments
 (0)