@@ -836,9 +836,7 @@ static bool passCursorInfoForDecl(SourceFile* SF,
836
836
837
837
838
838
SmallVector<symbolgraphgen::PathComponent, 4 > PathComponents;
839
- SmallVector<ParentInfo, 4 > Parents;
840
839
unsigned SymbolGraphBegin = SS.size ();
841
- unsigned SymbolGraphEnd = SymbolGraphBegin;
842
840
if (SymbolGraph) {
843
841
symbolgraphgen::SymbolGraphOptions Options {
844
842
" " ,
@@ -851,16 +849,16 @@ static bool passCursorInfoForDecl(SourceFile* SF,
851
849
symbolgraphgen::printSymbolGraphForDecl (VD, BaseType,
852
850
InSynthesizedExtension, Options, OS,
853
851
PathComponents);
854
- SymbolGraphEnd = SS.size ();
855
-
856
- for (auto &Component: PathComponents) {
857
- unsigned USRStart = SS.size ();
858
- if (SwiftLangSupport::printUSR (Component.VD , OS))
859
- continue ;
860
- StringRef USR{SS.begin ()+USRStart, SS.size () - USRStart};
861
- Parents.push_back ({Component.Title , Component.Kind , USR});
862
- }
863
852
}
853
+ unsigned SymbolGraphEnd = SS.size ();
854
+
855
+ DelayedStringRetriever ParentUSRsOS (SS);
856
+ for (auto &Component: PathComponents) {
857
+ ParentUSRsOS.startPiece ();
858
+ if (SwiftLangSupport::printUSR (Component.VD , OS))
859
+ ParentUSRsOS.startPiece (); // ignore any output if invalid
860
+ ParentUSRsOS.endPiece ();
861
+ };
864
862
865
863
unsigned FullDeclBegin = SS.size ();
866
864
{
@@ -995,6 +993,15 @@ static bool passCursorInfoForDecl(SourceFile* SF,
995
993
StringRef SymbolGraphJSON = StringRef (SS.begin ()+SymbolGraphBegin,
996
994
SymbolGraphEnd-SymbolGraphBegin);
997
995
996
+ SmallVector<ParentInfo, 4 > Parents;
997
+ auto ParentIt = PathComponents.begin ();
998
+ ParentUSRsOS.retrieve ([&](StringRef ParentUSR) {
999
+ assert (ParentIt != PathComponents.end ());
1000
+ if (!ParentUSR.empty ())
1001
+ Parents.push_back ({ParentIt->Title , ParentIt->Kind , ParentUSR});
1002
+ ++ParentIt;
1003
+ });
1004
+
998
1005
// If VD is the syntehsized property wrapper backing storage (_foo) or
999
1006
// projected value ($foo) of a property (foo), base the location on that
1000
1007
// property instead.
0 commit comments