aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-02-07 16:05:45 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-02-22 11:55:40 +0900
commit25b0577c9266e3e2e3ec4870c9aa8b0733978b38 (patch)
treeccd86a6061e4c6e4ab47650cc7f5f80c1a365179 /error.c
parenteda10e81023dfc258eab106f00830c5c1de7ac24 (diff)
downloadruby-25b0577c9266e3e2e3ec4870c9aa8b0733978b38.tar.gz
Factor a "highlight" symbol out
Diffstat (limited to 'error.c')
-rw-r--r--error.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/error.c b/error.c
index 079c171198..24df7ce064 100644
--- a/error.c
+++ b/error.c
@@ -77,6 +77,7 @@ static ID id_category;
static ID id_deprecated;
static ID id_experimental;
static VALUE sym_category;
+static VALUE sym_highlight;
static struct {
st_table *id2enum, *enum2id;
} warning_categories;
@@ -1268,10 +1269,7 @@ check_highlight_keyword(VALUE opt, int auto_tty_detect)
VALUE highlight = Qnil;
if (!NIL_P(opt)) {
- static VALUE kw_highlight;
- if (!kw_highlight) kw_highlight = ID2SYM(rb_intern_const("highlight"));
-
- highlight = rb_hash_aref(opt, kw_highlight);
+ highlight = rb_hash_aref(opt, sym_highlight);
switch (highlight) {
default:
@@ -1351,10 +1349,8 @@ exc_full_message(int argc, VALUE *argv, VALUE exc)
order = check_order_keyword(opt);
{
- static VALUE kw_highlight;
- if (!kw_highlight) kw_highlight = ID2SYM(rb_intern_const("highlight"));
if (NIL_P(opt)) opt = rb_hash_new();
- rb_hash_aset(opt, kw_highlight, highlight);
+ rb_hash_aset(opt, sym_highlight, highlight);
}
str = rb_str_new2("");
@@ -3076,6 +3072,7 @@ Init_Exception(void)
id_recv = rb_make_internal_id();
sym_category = ID2SYM(id_category);
+ sym_highlight = ID2SYM(rb_intern_const("highlight"));
warning_categories.id2enum = rb_init_identtable();
st_add_direct(warning_categories.id2enum, id_deprecated, RB_WARN_CATEGORY_DEPRECATED);