@@ -29,9 +29,6 @@ struct SyntaxArena::Implementation {
29
29
// / List of pointers to the allocated RawSyntax
30
30
std::vector<RawSyntax *> AllocatedRawSyntaxList;
31
31
32
- // / Cached Tokens.
33
- llvm::FoldingSet<RawSyntaxCacheNode> CachedTokens;
34
-
35
32
Implementation () = default ;
36
33
void *Allocate (size_t size, size_t alignment) {
37
34
return Allocator.Allocate (size, alignment);
@@ -125,38 +122,6 @@ RC<RawSyntax> RawSyntax::getToken(SyntaxArena &Arena, tok TokKind,
125
122
llvm::ArrayRef<TriviaPiece> LeadingTrivia,
126
123
llvm::ArrayRef<TriviaPiece> TrailingTrivia) {
127
124
128
- // Determine whether this token is worth to cache.
129
- if (
130
- // Is string_literal with >16 length.
131
- (TokKind == tok::string_literal && Text.size () > 16 ) ||
132
- // Has leading comment trivia et al.
133
- any_of (LeadingTrivia,
134
- [](const syntax::TriviaPiece &T) { return T.getText ().size (); }) ||
135
- // Has trailing comment trivia et al.
136
- any_of (TrailingTrivia,
137
- [](const syntax::TriviaPiece &T) { return T.getText ().size (); })) {
138
-
139
- // Do not use cache.
140
- return RawSyntax::make (TokKind, Text, LeadingTrivia, TrailingTrivia,
141
- SourcePresence::Present, &Arena);
142
- }
143
-
144
- // This node is cacheable. Get or create.
145
- auto &CachedTokens = Arena.Impl .CachedTokens ;
146
-
147
- llvm::FoldingSetNodeID ID;
148
- RawSyntax::Profile (ID, TokKind, Text, LeadingTrivia, TrailingTrivia);
149
-
150
- void *insertPos = nullptr ;
151
- if (auto existing = CachedTokens.FindNodeOrInsertPos (ID, insertPos))
152
- // Found in the cache. Just return it.
153
- return existing->get ();
154
-
155
- // Could not found in the cache. Create it.
156
- auto Raw = RawSyntax::make (TokKind, Text, LeadingTrivia, TrailingTrivia,
157
- SourcePresence::Present, &Arena);
158
- auto IDRef = ID.Intern (Arena.getAllocator ());
159
- auto CacheNode = new (Arena) RawSyntaxCacheNode (Raw.get (), IDRef);
160
- CachedTokens.InsertNode (CacheNode, insertPos);
161
- return Raw;
125
+ return RawSyntax::make (TokKind, Text, LeadingTrivia, TrailingTrivia,
126
+ SourcePresence::Present, &Arena);
162
127
}
0 commit comments