@@ -660,7 +660,7 @@ class SwiftDocumentSemanticInfo :
660
660
}
661
661
662
662
private:
663
- std::vector<SwiftSemanticToken> getSemanticTokens (
663
+ std::vector<SwiftSemanticToken> takeSemanticTokens (
664
664
ImmutableTextSnapshotRef NewSnapshot);
665
665
666
666
Optional<std::vector<DiagnosticEntryInfo>> getSemanticDiagnostics (
@@ -763,28 +763,26 @@ void SwiftDocumentSemanticInfo::readSemanticInfo(
763
763
764
764
llvm::sys::ScopedLock L (Mtx);
765
765
766
- Tokens = getSemanticTokens (NewSnapshot);
766
+ Tokens = takeSemanticTokens (NewSnapshot);
767
767
Diags = getSemanticDiagnostics (NewSnapshot, ParserDiags);
768
768
}
769
769
770
770
std::vector<SwiftSemanticToken>
771
- SwiftDocumentSemanticInfo::getSemanticTokens (
771
+ SwiftDocumentSemanticInfo::takeSemanticTokens (
772
772
ImmutableTextSnapshotRef NewSnapshot) {
773
773
774
774
llvm::sys::ScopedLock L (Mtx);
775
775
776
776
if (SemaToks.empty ())
777
777
return {};
778
778
779
- auto result = SemaToks;
780
-
781
779
// Adjust the position of the tokens.
782
780
TokSnapshot->foreachReplaceUntil (NewSnapshot,
783
781
[&](ReplaceImmutableTextUpdateRef Upd) -> bool {
784
- if (result .empty ())
782
+ if (SemaToks .empty ())
785
783
return false ;
786
784
787
- auto ReplaceBegin = std::lower_bound (result .begin (), result .end (),
785
+ auto ReplaceBegin = std::lower_bound (SemaToks .begin (), SemaToks .end (),
788
786
Upd->getByteOffset (),
789
787
[&](const SwiftSemanticToken &Tok, unsigned StartOffset) -> bool {
790
788
return Tok.ByteOffset +Tok.Length < StartOffset;
@@ -794,7 +792,7 @@ SwiftDocumentSemanticInfo::getSemanticTokens(
794
792
if (Upd->getLength () == 0 ) {
795
793
ReplaceEnd = ReplaceBegin;
796
794
} else {
797
- ReplaceEnd = std::upper_bound (ReplaceBegin, result .end (),
795
+ ReplaceEnd = std::upper_bound (ReplaceBegin, SemaToks .end (),
798
796
Upd->getByteOffset () + Upd->getLength (),
799
797
[&](unsigned EndOffset, const SwiftSemanticToken &Tok) -> bool {
800
798
return EndOffset < Tok.ByteOffset ;
@@ -805,14 +803,14 @@ SwiftDocumentSemanticInfo::getSemanticTokens(
805
803
int Delta = InsertLen - Upd->getLength ();
806
804
if (Delta != 0 ) {
807
805
for (std::vector<SwiftSemanticToken>::iterator
808
- I = ReplaceEnd, E = result .end (); I != E; ++I)
806
+ I = ReplaceEnd, E = SemaToks .end (); I != E; ++I)
809
807
I->ByteOffset += Delta;
810
808
}
811
- result .erase (ReplaceBegin, ReplaceEnd);
809
+ SemaToks .erase (ReplaceBegin, ReplaceEnd);
812
810
return true ;
813
811
});
814
812
815
- return result ;
813
+ return std::move (SemaToks) ;
816
814
}
817
815
818
816
Optional<std::vector<DiagnosticEntryInfo>>
0 commit comments