RVList <LNode> ApplyMacrosToList(RVList <LNode> list, int maxExpansions) { RVList <LNode> results = list; LNode result = null; int i, c; // Share as much of the original RVList as is left unchanged for (i = 0, c = list.Count; i < c; i++) { if ((result = ApplyMacros(list[i], maxExpansions)) != null || (result = list[i]).Calls(S.Splice)) { results = list.WithoutLast(c - i); Add(ref results, result); break; } } // Prepare a modified list from now on for (i++; i < c; i++) { LNode input = list[i]; if ((result = ApplyMacros(input, maxExpansions)) != null) { Add(ref results, result); } else { results.Add(input); } } return(results); }
RVList <LNode> ApplyMacrosToList(RVList <LNode> list, int maxExpansions, bool areAttributes) { RVList <LNode> results = list; LNode result = null; int i, count; // Share as much of the original RVList as is left unchanged for (i = 0, count = list.Count; i < count; i++) { _s.StartNextListItem(list, i, areAttributes); LNode input = list[i]; result = ApplyMacros(input, maxExpansions, false); if (result != null || (result = input).Calls(S.Splice)) { results = list.WithoutLast(count - i); Add(ref results, result); break; } } // Prepare a modified list from now on for (i++; i < count && !_s.DropRemainingNodes; i++) { _s.StartNextListItem(list, i, areAttributes); LNode input = list[i]; result = ApplyMacros(input, maxExpansions, false); if (result != null || (result = input).Calls(S.Splice)) { Add(ref results, result); } else { results.Add(input); } } _s.DropRemainingNodes = false; _s.IsAttribute = false; return(results); }