private static GreenNode CreateNode(SyntaxTrivia[] trivias) { if (trivias == null) { return(null); } var builder = new SyntaxTriviaListBuilder(trivias.Length); builder.Add(trivias); return(builder.ToList().Node); }
public static SyntaxTriviaList Create(IEnumerable <SyntaxTrivia> trivia) { if (trivia == null) { return(new SyntaxTriviaList()); } var builder = SyntaxTriviaListBuilder.Create(); builder.AddRange(trivia); return(builder.ToList()); }
private static void ClearAndFreeBuilder(SyntaxTriviaListBuilder builder) { // It's possible someone might create a list with a huge amount of trivia // in it. We don't want to hold onto such items forever. So only cache // reasonably sized lists. In IDE testing, around 99% of all trivia lists // were 16 or less elements. const int MaxBuilderCount = 16; if (builder.Count <= MaxBuilderCount) { builder.Clear(); s_builderPool.Free(builder); } }
/// <summary> /// Creates a list of trivia. /// </summary> /// <param name="trivias">A sequence of trivia.</param> public SyntaxTriviaList(IEnumerable <SyntaxTrivia> trivias) : this(null, SyntaxTriviaListBuilder.Create(trivias).Node, 0, 0) { }