@@ -177,12 +177,17 @@ static inline void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
177
177
}
178
178
}
179
179
180
- static void fbuffer_append (FBuffer *fb, const char *newstr, unsigned long len)
180
+ static inline void fbuffer_append_reserved (FBuffer *fb, const char *newstr, unsigned long len)
181
+ {
182
+ MEMCPY (fb->ptr + fb->len , newstr, char , len);
183
+ fbuffer_consumed (fb, len);
184
+ }
185
+
186
+ static inline void fbuffer_append (FBuffer *fb, const char *newstr, unsigned long len)
181
187
{
182
188
if (len > 0 ) {
183
189
fbuffer_inc_capa (fb, len);
184
- MEMCPY (fb->ptr + fb->len , newstr, char , len);
185
- fbuffer_consumed (fb, len);
190
+ fbuffer_append_reserved (fb, newstr, len);
186
191
}
187
192
}
188
193
@@ -210,13 +215,15 @@ static void fbuffer_append_str(FBuffer *fb, VALUE str)
210
215
211
216
static void fbuffer_append_str_repeat (FBuffer *fb, VALUE str, size_t repeat)
212
217
{
218
+ const char *newstr = StringValuePtr (str);
213
219
unsigned long len = RSTRING_LEN (str);
214
220
215
- size_t total = repeat * len;
216
- fbuffer_inc_capa (fb, total);
217
-
221
+ fbuffer_inc_capa (fb, repeat * len);
218
222
while (repeat) {
219
- fbuffer_append_str (fb, str);
223
+ #ifdef JSON_DEBUG
224
+ fb->requested = len;
225
+ #endif
226
+ fbuffer_append_reserved (fb, newstr, len);
220
227
repeat--;
221
228
}
222
229
}
0 commit comments