mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-sprintf/sprintf.c: call mrb_str_resize() less often.
This commit is contained in:
@@ -153,12 +153,14 @@ 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 (bsiz > MRB_INT_MAX/2) mrb_raise(mrb, E_ARGUMENT_ERROR, "too big specifier"); \
|
||||
bsiz*=2;\
|
||||
#define CHECK(l) do { \
|
||||
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);\
|
||||
}\
|
||||
mrb_str_resize(mrb, result, bsiz);\
|
||||
buf = RSTRING_PTR(result);\
|
||||
} while (0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user