From dd6234974932382181ced7a813ad71d426d1e0ab Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Sat, 23 Feb 2013 21:21:15 +0900 Subject: Reduce sprintf() calls. Remove mrb_int_to_str() and MRB_INT_FORMAT. --- src/dump.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/dump.c') diff --git a/src/dump.c b/src/dump.c index e8d96c570..b97b38dc2 100644 --- a/src/dump.c +++ b/src/dump.c @@ -10,6 +10,7 @@ #include "mruby/string.h" #include "mruby/irep.h" +#include "mruby/numeric.h" static const unsigned char def_rite_binary_header[] = RITE_FILE_IDENFIFIER @@ -241,8 +242,8 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep, int type) switch (mrb_type(irep->pool[pool_no])) { case MRB_TT_FIXNUM: - len = mrb_int_to_str( buf, mrb_fixnum(irep->pool[pool_no])); - size += (uint32_t)len; + str = mrb_fix2str(mrb, irep->pool[pool_no], 10); + size += (uint32_t)RSTRING_LEN(str); break; case MRB_TT_FLOAT: len = mrb_float_to_str( buf, mrb_float(irep->pool[pool_no])); @@ -358,7 +359,9 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type) switch (mrb_type(irep->pool[pool_no])) { case MRB_TT_FIXNUM: - len = mrb_int_to_str(char_buf, mrb_fixnum(irep->pool[pool_no])); + str = mrb_fix2str(mrb, irep->pool[pool_no], 10); + memcpy(char_buf, RSTRING_PTR(str), RSTRING_LEN(str)); + len = RSTRING_LEN(str); break; case MRB_TT_FLOAT: -- cgit v1.2.3