@@ -129,8 +129,8 @@ internal ProcessResult Apply(List<Line> lines, string newLine, string? relativeP
129129 var missingSnippets = new List < MissingSnippet > ( ) ;
130130 var validationErrors = new List < ValidationError > ( ) ;
131131 var missingIncludes = new List < MissingInclude > ( ) ;
132- var usedSnippets = new List < Snippet > ( ) ;
133- var usedIncludes = new List < Include > ( ) ;
132+ var usedSnippets = new HashSet < Snippet > ( ) ;
133+ var usedIncludes = new HashSet < Include > ( ) ;
134134 var builder = new StringBuilder ( ) ;
135135 Line ? tocLine = null ;
136136
@@ -263,8 +263,8 @@ void AppendWebSnippet(string url, string snippetKey, string? viewUrl = null)
263263
264264 return new (
265265 missingSnippets : missingSnippets ,
266- usedSnippets : usedSnippets . Distinct ( ) . ToList ( ) ,
267- usedIncludes : usedIncludes . Distinct ( ) . ToList ( ) ,
266+ usedSnippets : usedSnippets . ToList ( ) ,
267+ usedIncludes : usedIncludes . ToList ( ) ,
268268 missingIncludes : missingIncludes ,
269269 validationErrors : validationErrors ) ;
270270 }
@@ -292,15 +292,15 @@ bool ValidateContent(string? relativePath, Line line, List<ValidationError> vali
292292 return found ;
293293 }
294294
295- void ProcessSnippetLine ( Action < string > appendLine , List < MissingSnippet > missings , List < Snippet > used , string key , string ? relativePath , Line line )
295+ void ProcessSnippetLine ( Action < string > appendLine , List < MissingSnippet > missings , HashSet < Snippet > used , string key , string ? relativePath , Line line )
296296 {
297297 appendLine ( $ "<!-- snippet: { key } -->") ;
298298
299299 if ( TryGetSnippets ( key , relativePath , line . Path , out var snippetsForKey ) )
300300 {
301301 appendSnippets ( key , snippetsForKey , appendLine ) ;
302302 appendLine ( "<!-- endSnippet -->" ) ;
303- used . AddRange ( snippetsForKey ) ;
303+ used . UnionWith ( snippetsForKey ) ;
304304 return ;
305305 }
306306
@@ -312,7 +312,7 @@ void ProcessSnippetLine(Action<string> appendLine, List<MissingSnippet> missings
312312 appendLine ( "<!-- endSnippet -->" ) ;
313313 }
314314
315- void ProcessWebSnippetLine ( Action < string > appendLine , List < MissingSnippet > missings , List < Snippet > used , string url , string snippetKey , string ? viewUrl , Line line )
315+ void ProcessWebSnippetLine ( Action < string > appendLine , List < MissingSnippet > missings , HashSet < Snippet > used , string url , string snippetKey , string ? viewUrl , Line line )
316316 {
317317 var commentText = viewUrl == null
318318 ? $ "<!-- web-snippet: { url } #{ snippetKey } -->"
0 commit comments