diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-09 05:05:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-09 05:05:12 +0000 |
commit | f82df94f390a104be47b57e45801409be23954a9 (patch) | |
tree | a12c78756755ebd30bea2cbd7faee137924a18dc | |
parent | 3f6401864aad925701804ea003ec834f123dfbc9 (diff) | |
download | ruby-f82df94f390a104be47b57e45801409be23954a9.tar.gz |
tcltklib.c: repeated checks and conversions [ci skip]
* ext/tk/tcltklib.c (ip_init): get rid of repeated checks and
conversions in StringValueCStr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ext/tk/tcltklib.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index 721f497ef4..1e425d7654 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -6215,14 +6215,16 @@ ip_init(argc, argv, self) case 1: /* argv0 */ if (!NIL_P(argv0)) { - if (strncmp(StringValueCStr(argv0), "-e", 3) == 0 - || strncmp(StringValueCStr(argv0), "-", 2) == 0) { - Tcl_SetVar(ptr->ip, "argv0", "ruby", TCL_GLOBAL_ONLY); + const char *name = StringValueCStr(argv0); + long len = RSTRING_LEN(argv0); + int flag = TCL_GLOBAL_ONLY; + if ((len == 2 && memcmp(name, "-e", 2) == 0) + || (len == 1 && memcmp(name, "-", 1) == 0)) { + name = "ruby"; } else { - /* Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), 0); */ - Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), - TCL_GLOBAL_ONLY); + /* flag = 0; */ } + Tcl_SetVar(ptr->ip, "argv0", name, flag); } case 0: /* no args */ |