mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[Bug #19167] Remove useless conversion of classes for special const
This commit is contained in:
parent
181d4bee5e
commit
11acb7f7bc
2 changed files with 13 additions and 21 deletions
26
sprintf.c
26
sprintf.c
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue