@@ -19,6 +19,7 @@ public void AppendFormat<T>(
1919 T arg )
2020 {
2121 var formatIndex = 0 ;
22+ var start = 0 ;
2223 while ( formatIndex < format . Length )
2324 {
2425 var c = format [ formatIndex ] ;
@@ -31,19 +32,29 @@ public void AppendFormat<T>(
3132 return ;
3233 }
3334
35+ if ( start != formatIndex )
36+ {
37+ Append ( format [ start ..formatIndex ] ) ;
38+ }
39+
3440 var placeholder = format . Slice ( formatIndex , endIndex + 2 ) ;
3541
3642 GetValidArgumentIndex ( placeholder , 0 ) ;
3743
3844 AppendInternal ( arg ) ;
3945 formatIndex += endIndex + 2 ;
46+ start = formatIndex ;
4047 }
4148 else
4249 {
43- Append ( c ) ;
4450 formatIndex ++ ;
4551 }
4652 }
53+
54+ if ( start != formatIndex )
55+ {
56+ Append ( format [ start ..formatIndex ] ) ;
57+ }
4758 }
4859
4960 /// <summary>
@@ -64,6 +75,7 @@ public void AppendFormat<T1, T2>(
6475 T2 arg2 )
6576 {
6677 var formatIndex = 0 ;
78+ var start = 0 ;
6779 while ( formatIndex < format . Length )
6880 {
6981 var c = format [ formatIndex ] ;
@@ -76,6 +88,11 @@ public void AppendFormat<T1, T2>(
7688 return ;
7789 }
7890
91+ if ( start != formatIndex )
92+ {
93+ Append ( format [ start ..formatIndex ] ) ;
94+ }
95+
7996 var placeholder = format . Slice ( formatIndex , endIndex + 2 ) ;
8097
8198 var index = GetValidArgumentIndex ( placeholder , 1 ) ;
@@ -91,13 +108,18 @@ public void AppendFormat<T1, T2>(
91108 }
92109
93110 formatIndex += endIndex + 2 ;
111+ start = formatIndex ;
94112 }
95113 else
96114 {
97- Append ( c ) ;
98115 formatIndex ++ ;
99116 }
100117 }
118+
119+ if ( start != formatIndex )
120+ {
121+ Append ( format [ start ..formatIndex ] ) ;
122+ }
101123 }
102124
103125 /// <summary>
@@ -121,6 +143,7 @@ public void AppendFormat<T1, T2, T3>(
121143 T3 arg3 )
122144 {
123145 var formatIndex = 0 ;
146+ var start = 0 ;
124147 while ( formatIndex < format . Length )
125148 {
126149 var c = format [ formatIndex ] ;
@@ -133,6 +156,11 @@ public void AppendFormat<T1, T2, T3>(
133156 return ;
134157 }
135158
159+ if ( start != formatIndex )
160+ {
161+ Append ( format [ start ..formatIndex ] ) ;
162+ }
163+
136164 var placeholder = format . Slice ( formatIndex , endIndex + 2 ) ;
137165
138166 var index = GetValidArgumentIndex ( placeholder , 2 ) ;
@@ -151,13 +179,18 @@ public void AppendFormat<T1, T2, T3>(
151179 }
152180
153181 formatIndex += endIndex + 2 ;
182+ start = formatIndex ;
154183 }
155184 else
156185 {
157- Append ( c ) ;
158186 formatIndex ++ ;
159187 }
160188 }
189+
190+ if ( start != formatIndex )
191+ {
192+ Append ( format [ start ..formatIndex ] ) ;
193+ }
161194 }
162195
163196 private static int GetValidArgumentIndex ( ReadOnlySpan < char > placeholder , int allowedRange )
0 commit comments