diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-01 10:09:28 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-01 10:09:28 +0000 |
commit | 87ecfbd7737d68f2533f30213b19f9eeb569d477 (patch) | |
tree | c4280fe6040d095d095d44ee3251f232d03cbcba /ext/tk | |
parent | 5b9896ea2453ee3e0cdcc3b446bc501406e935d4 (diff) | |
download | ruby-87ecfbd7737d68f2533f30213b19f9eeb569d477.tar.gz |
* ext/tk/tcltklib.c: refactoring - replaced rb_ivar_defined &
rb_ivar_get with single rb_attr_get call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/tcltklib.c | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index d0f52baa1e..a350a7e038 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -2014,12 +2014,9 @@ ip_set_exc_message(interp, exc) msg = rb_funcall(exc, ID_message, 0, 0); #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) - enc = Qnil; - if (RTEST(rb_ivar_defined(exc, ID_at_enc))) { - enc = rb_ivar_get(exc, ID_at_enc); - } - if (NIL_P(enc) && RTEST(rb_ivar_defined(msg, ID_at_enc))) { - enc = rb_ivar_get(msg, ID_at_enc); + enc = rb_attr_get(exc, ID_at_enc); + if (NIL_P(enc)) { + enc = rb_attr_get(msg, ID_at_enc); } if (NIL_P(enc)) { encoding = (Tcl_Encoding)NULL; @@ -6181,18 +6178,12 @@ lib_toUTF8_core(ip_obj, src, encodename) if (NIL_P(encodename)) { if (TYPE(str) == T_STRING) { volatile VALUE enc; - - enc = Qnil; - if (RTEST(rb_ivar_defined(str, ID_at_enc))) { - enc = rb_ivar_get(str, ID_at_enc); - } + enc = rb_attr_get(str, ID_at_enc); if (NIL_P(enc)) { if (NIL_P(ip_obj)) { encoding = (Tcl_Encoding)NULL; } else { - if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { - enc = rb_ivar_get(ip_obj, ID_at_enc); - } + enc = rb_attr_get(ip_obj, ID_at_enc); if (NIL_P(enc)) { encoding = (Tcl_Encoding)NULL; } else { @@ -6330,10 +6321,7 @@ lib_fromUTF8_core(ip_obj, src, encodename) volatile VALUE enc; if (TYPE(str) == T_STRING) { - enc = Qnil; - if (RTEST(rb_ivar_defined(str, ID_at_enc))) { - enc = rb_ivar_get(str, ID_at_enc); - } + enc = rb_attr_get(str, ID_at_enc); if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { rb_thread_critical = thr_crit_bup; return str; @@ -6343,10 +6331,7 @@ lib_fromUTF8_core(ip_obj, src, encodename) if (NIL_P(ip_obj)) { encoding = (Tcl_Encoding)NULL; } else { - enc = Qnil; - if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) { - enc = rb_ivar_get(ip_obj, ID_at_enc); - } + enc = rb_attr_get(ip_obj, ID_at_enc); if (NIL_P(enc)) { encoding = (Tcl_Encoding)NULL; } else { @@ -6887,10 +6872,7 @@ alloc_invoke_arguments(argc, argv) # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 av[i] = Tcl_NewStringObj(s, RSTRING(v)->len); # else /* TCL_VERSION >= 8.1 */ - enc = Qnil; - if (RTEST(rb_ivar_defined(v, ID_at_enc))) { - enc = rb_ivar_get(v, ID_at_enc); - } + enc = rb_attr_get(v, ID_at_enc); if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { /* binary string */ av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len); @@ -7535,11 +7517,7 @@ ip_set_variable_core(interp, argc, argv) Tcl_IncrRefCount(valobj); # else /* TCL_VERSION >= 8.1 */ { - volatile VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(value, ID_at_enc))) { - enc = rb_ivar_get(value, ID_at_enc); - } + volatile VALUE enc = rb_attr_get(value, ID_at_enc); if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { /* binary string */ @@ -7718,11 +7696,7 @@ ip_set_variable2_core(interp, argc, argv) RSTRING(value)->len); # else /* TCL_VERSION >= 8.1 */ { - VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(value, ID_at_enc))) { - enc = rb_ivar_get(value, ID_at_enc); - } + VALUE enc = rb_attr_get(value, ID_at_enc); if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { /* binary string */ @@ -8091,11 +8065,7 @@ lib_split_tklist_core(ip_obj, list_str) rb_thread_critical = Qtrue; { - VALUE enc = Qnil; - - if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) { - enc = rb_ivar_get(list_str, ID_at_enc); - } + VALUE enc = rb_attr_get(list_str, ID_at_enc); if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) { /* binary string */ |