Skip to content

Commit 22697aa

Browse files
authored
[SourceKit] Declaring locally used UIdent static so that we don't need to create them in every request. NFC (#10762)
This addresses @@benlangmuir's code review comments.
1 parent 4671c40 commit 22697aa

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,14 @@ handleSemanticRequest(RequestDict Req,
752752
if (!NK) {
753753
return Rec(createErrorRequestInvalid("'key.namekind' is required"));
754754
}
755+
756+
static UIdent UIDKindNameSwift(KindNameSwift.str());
757+
static UIdent UIDKindNameObjc(KindNameObjc.str());
758+
755759
if (NK == KindNameSwift.get())
756-
Input.NameKind = UIdent(KindNameSwift.str());
760+
Input.NameKind = UIDKindNameSwift;
757761
else if (NK == KindNameObjc.get())
758-
Input.NameKind = UIdent(KindNameObjc.str());
762+
Input.NameKind = UIDKindNameObjc;
759763
else
760764
return Rec(createErrorRequestInvalid("'key.namekind' is unrecognizable"));
761765
if (auto Base = Req.getString(KeyBaseName)) {
@@ -1310,12 +1314,14 @@ bool SKDocConsumer::handleDiagnostic(const DiagnosticEntryInfo &Info) {
13101314

13111315
auto Elem = Arr.appendDictionary();
13121316
UIdent SeverityUID;
1317+
static UIdent UIDKindDiagWarning(KindDiagWarning.str());
1318+
static UIdent UIDKindDiagError(KindDiagError.str());
13131319
switch (Info.Severity) {
13141320
case DiagnosticSeverityKind::Warning:
1315-
SeverityUID = UIdent(KindDiagWarning.str());
1321+
SeverityUID = UIDKindDiagWarning;
13161322
break;
13171323
case DiagnosticSeverityKind::Error:
1318-
SeverityUID = UIdent(KindDiagError.str());
1324+
SeverityUID = UIDKindDiagError;
13191325
break;
13201326
}
13211327

@@ -1453,8 +1459,9 @@ static void reportNameInfo(const NameTranslatingInfo &Info, ResponseReceiver Rec
14531459
Elem.set(KeyBaseName, Info.BaseName);
14541460
}
14551461
if (!Info.ArgNames.empty()) {
1456-
auto Arr = Elem.setArray(Info.NameKind == UIdent(KindNameSwift.str()) ?
1457-
KeyArgNames : KeySelectorPieces);
1462+
static UIdent UIDKindNameSwift(KindNameSwift.str());
1463+
auto Arr = Elem.setArray(Info.NameKind == UIDKindNameSwift ?
1464+
KeyArgNames : KeySelectorPieces);
14581465
for (auto N : Info.ArgNames) {
14591466
auto NameEle = Arr.appendDictionary();
14601467
NameEle.set(KeyName, N);
@@ -2204,12 +2211,14 @@ bool SKEditorConsumer::handleDiagnostic(const DiagnosticEntryInfo &Info,
22042211

22052212
auto Elem = Arr.appendDictionary();
22062213
UIdent SeverityUID;
2214+
static UIdent UIDKindDiagWarning(KindDiagWarning.str());
2215+
static UIdent UIDKindDiagError(KindDiagError.str());
22072216
switch (Info.Severity) {
22082217
case DiagnosticSeverityKind::Warning:
2209-
SeverityUID = UIdent(KindDiagWarning.str());
2218+
SeverityUID = UIDKindDiagWarning;
22102219
break;
22112220
case DiagnosticSeverityKind::Error:
2212-
SeverityUID = UIdent(KindDiagError.str());
2221+
SeverityUID = UIDKindDiagError;
22132222
break;
22142223
}
22152224

0 commit comments

Comments
 (0)