Rewrite Symbol#to_sym and #intern in Ruby (#6683)

This commit is contained in:
Takashi Kokubun 2022-11-15 21:34:30 -08:00 committed by GitHub
parent 41b0f641ef
commit e7443dbbca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-11-16 05:34:59 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
6 changed files with 24 additions and 19 deletions

View file

@ -11524,23 +11524,6 @@ rb_sym_to_s(VALUE sym)
return str_new_shared(rb_cString, rb_sym2str(sym));
}
/*
* call-seq:
* to_sym -> self
*
* Returns +self+.
*
* Symbol#intern is an alias for Symbol#to_sym.
*
* Related: String#to_sym.
*/
static VALUE
sym_to_sym(VALUE sym)
{
return sym;
}
MJIT_FUNC_EXPORTED VALUE
rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
{
@ -12107,8 +12090,6 @@ Init_String(void)
rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0);
rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0);
rb_define_method(rb_cSymbol, "name", rb_sym2str, 0); /* in symbol.c */
rb_define_method(rb_cSymbol, "intern", sym_to_sym, 0);
rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
rb_define_method(rb_cSymbol, "to_proc", rb_sym_to_proc, 0); /* in proc.c */
rb_define_method(rb_cSymbol, "succ", sym_succ, 0);
rb_define_method(rb_cSymbol, "next", sym_succ, 0);