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:
parent
41703fcfab
commit
bf19820bb3
Notes:
git
2020-06-29 11:06:59 +09:00
25
numeric.c
25
numeric.c
@ -985,19 +985,22 @@ flo_to_s(VALUE flt)
|
|||||||
memcpy(ptr -= decpt, buf, digs);
|
memcpy(ptr -= decpt, buf, digs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
exp:
|
goto 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;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user