mruby-sprintf/sprintf.c: call mrb_str_resize() less often.
@@ -154,11 +154,13 @@ fmt_float(char *buf, size_t buf_size, char fmt, int flags, mrb_int width, int pr
#endif
#define CHECK(l) do { \
- while ((l) >= bsiz - blen) {\
+ if (blen+(l) >= bsiz) {\
+ while (blen+(l) >= bsiz) {\
if (bsiz > MRB_INT_MAX/2) mrb_raise(mrb, E_ARGUMENT_ERROR, "too big specifier");\
bsiz*=2;\
}\
mrb_str_resize(mrb, result, bsiz);\
+ }\
buf = RSTRING_PTR(result);\
} while (0)
