flo_to_s: do not goto into a branch

I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
This commit is contained in:
卜部昌平 2020-06-16 09:42:18 +09:00
Родитель 41703fcfab
Коммит bf19820bb3
1 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -985,19 +985,22 @@ flo_to_s(VALUE flt)
memcpy(ptr -= decpt, buf, digs);
}
else {
exp:
if (digs > 1) {
memmove(buf + 2, buf + 1, digs - 1);
}
else {
buf[2] = '0';
digs++;
}
buf[1] = '.';
rb_str_cat(s, buf, digs + 1);
rb_str_catf(s, "e%+03d", decpt - 1);
goto exp;
}
return s;
exp:
if (digs > 1) {
memmove(buf + 2, buf + 1, digs - 1);
}
else {
buf[2] = '0';
digs++;
}
buf[1] = '.';
rb_str_cat(s, buf, digs + 1);
rb_str_catf(s, "e%+03d", decpt - 1);
return s;
}
/*