summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-15 15:15:23 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-15 15:19:23 +0900
commitce6fafb8cc59658245a70ff24c75a3108a39ba93 (patch)
tree934557f07a9ac4233d0320b90201064b15e3f419 /error.c
parenta86c147579745859ea064ec22b2901a7ac7e4abf (diff)
Cache warning category IDs
Diffstat (limited to 'error.c')
-rw-r--r--error.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/error.c b/error.c
index 1d9b66c328..e10485dc4e 100644
--- a/error.c
+++ b/error.c
@@ -73,6 +73,8 @@ static VALUE rb_cWarningBuffer;
static ID id_warn;
static ID id_category;
+static ID id_deprecated;
+static ID id_experimental;
static VALUE sym_category;
static VALUE warning_categories;
@@ -160,10 +162,10 @@ rb_warning_category_from_name(VALUE category)
{
rb_warning_category_t cat = RB_WARN_CATEGORY_NONE;
Check_Type(category, T_SYMBOL);
- if (category == ID2SYM(rb_intern("deprecated"))) {
+ if (category == ID2SYM(id_deprecated)) {
cat = RB_WARN_CATEGORY_DEPRECATED;
}
- else if (category == ID2SYM(rb_intern("experimental"))) {
+ else if (category == ID2SYM(id_experimental)) {
cat = RB_WARN_CATEGORY_EXPERIMENTAL;
}
else {
@@ -475,7 +477,7 @@ rb_warn_deprecated(const char *fmt, const char *suggest, ...)
rb_str_cat_cstr(mesg, " is deprecated");
if (suggest) rb_str_catf(mesg, "; use %s instead", suggest);
rb_str_cat_cstr(mesg, "\n");
- rb_warn_category(mesg, ID2SYM(rb_intern("deprecated")));
+ rb_warn_category(mesg, ID2SYM(id_deprecated));
}
void
@@ -489,7 +491,7 @@ rb_warn_deprecated_to_remove(const char *fmt, const char *removal, ...)
va_end(args);
rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1);
rb_str_catf(mesg, " is deprecated and will be removed in Ruby %s\n", removal);
- rb_warn_category(mesg, ID2SYM(rb_intern("deprecated")));
+ rb_warn_category(mesg, ID2SYM(id_deprecated));
}
static inline int
@@ -2824,6 +2826,8 @@ Init_Exception(void)
id_i_path = rb_intern_const("@path");
id_warn = rb_intern_const("warn");
id_category = rb_intern_const("category");
+ id_deprecated = rb_intern_const("deprecated");
+ id_experimental = rb_intern_const("experimental");
id_top = rb_intern_const("top");
id_bottom = rb_intern_const("bottom");
id_iseq = rb_make_internal_id();