[Bug #19167] Remove useless conversion of classes for special const

This commit is contained in:
Nobuyoshi Nakada 2022-12-09 01:14:43 +09:00
parent 181d4bee5e
commit 11acb7f7bc
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 13 additions and 21 deletions

View file

@ -1106,26 +1106,16 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
}
if (sign == '+') {
if (RB_TYPE_P(value, T_CLASS)) {
# define LITERAL(str) (*sz = rb_strlen_lit(str), str)
if (value == rb_cNilClass) {
return LITERAL("nil");
}
else if (value == rb_cInteger) {
return LITERAL("Integer");
}
else if (value == rb_cSymbol) {
return LITERAL("Symbol");
}
else if (value == rb_cTrueClass) {
return LITERAL("true");
}
else if (value == rb_cFalseClass) {
return LITERAL("false");
}
# undef LITERAL
/* optimize special const cases */
switch (value) {
# define LITERAL_CASE(x) case Q##x: return LITERAL(#x)
LITERAL_CASE(nil);
LITERAL_CASE(true);
LITERAL_CASE(false);
# undef LITERAL_CASE
}
# undef LITERAL
value = rb_inspect(value);
}
else if (SYMBOL_P(value)) {