diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 14:42:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 14:42:08 +0000 |
commit | 05e2cba4dc2d2ddd48bbe849acaaa511e181a1a6 (patch) | |
tree | 3e6db7f9ecee480edff058e18bc7211a53296f64 /ext/tk | |
parent | cf4b4b4ed9283d87497b661fc1ac5172db6030c4 (diff) | |
download | ruby-05e2cba4dc2d2ddd48bbe849acaaa511e181a1a6.tar.gz ruby-05e2cba4dc2d2ddd48bbe849acaaa511e181a1a6.tar.xz ruby-05e2cba4dc2d2ddd48bbe849acaaa511e181a1a6.zip |
* ruby.h (struct RArray): embed small arrays.
(RARRAY_LEN): defined for accessing array members.
(RARRAY_PTR): ditto.
* array.c: use RARRAY_LEN and RARRAY_PTR.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/tcltklib.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index 6964c5f79..9086f3e4a 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -1133,15 +1133,15 @@ set_max_block_time(self, time) case T_BIGNUM: /* time is micro-second value */ divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000)); - tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); - tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]); + tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]); + tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]); break; case T_FLOAT: /* time is second value */ divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1)); - tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]); - tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000); + tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]); + tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000); default: { @@ -2595,15 +2595,14 @@ ip_ruby_cmd(clientData, interp, argc, argv) /* get args */ args = rb_ary_new2(argc - 2); - RARRAY(args)->len = 0; for(i = 3; i < argc; i++) { #if TCL_MAJOR_VERSION >= 8 str = Tcl_GetStringFromObj(argv[i], &len); DUMP2("arg:%s",str); - RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len); + rb_ary_push(args, rb_tainted_str_new(str, len)); #else /* TCL_MAJOR_VERSION < 8 */ DUMP2("arg:%s",argv[i]); - RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]); + rb_ary_push(args, rb_tainted_str_new2(argv[i])); #endif } @@ -5516,7 +5515,7 @@ call_queue_handler(evPtr, flags) } /* set result */ - RARRAY(q->result)->ptr[0] = ret; + RARRAY_PTR(q->result)[0] = ret; /* complete */ *(q->done) = -1; @@ -5586,8 +5585,8 @@ tk_funcall(func, argc, argv, obj) /* allocate result obj */ result = rb_ary_new2(1); - RARRAY(result)->ptr[0] = Qnil; - RARRAY(result)->len = 1; + RARRAY_PTR(result)[0] = Qnil; + RARRAY_LEN(result) = 1; /* construct event data */ callq->done = alloc_done; @@ -5614,7 +5613,7 @@ tk_funcall(func, argc, argv, obj) DUMP2("back from handler (current thread:%lx)", current); /* get result & free allocated memory */ - ret = RARRAY(result)->ptr[0]; + ret = RARRAY_PTR(result)[0]; free(alloc_done); if (argv) free(argv); @@ -5834,7 +5833,7 @@ eval_queue_handler(evPtr, flags) } /* set result */ - RARRAY(q->result)->ptr[0] = ret; + RARRAY_PTR(q->result)[0] = ret; /* complete */ *(q->done) = -1; @@ -5901,8 +5900,8 @@ ip_eval(self, str) /* allocate result obj */ result = rb_ary_new2(1); - RARRAY(result)->ptr[0] = Qnil; - RARRAY(result)->len = 1; + RARRAY_PTR(result)[0] = Qnil; + RARRAY_LEN(result) = 1; /* construct event data */ evq->done = alloc_done; @@ -5930,7 +5929,7 @@ ip_eval(self, str) DUMP2("back from handler (current thread:%lx)", current); /* get result & free allocated memory */ - ret = RARRAY(result)->ptr[0]; + ret = RARRAY_PTR(result)[0]; free(alloc_done); free(eval_str); @@ -6911,7 +6910,7 @@ invoke_queue_handler(evPtr, flags) } /* set result */ - RARRAY(q->result)->ptr[0] = ret; + RARRAY_PTR(q->result)[0] = ret; /* complete */ *(q->done) = -1; @@ -6981,8 +6980,8 @@ ip_invoke_with_position(argc, argv, obj, position) /* allocate result obj */ result = rb_ary_new2(1); - RARRAY(result)->ptr[0] = Qnil; - RARRAY(result)->len = 1; + RARRAY_PTR(result)[0] = Qnil; + RARRAY_LEN(result) = 1; /* construct event data */ ivq->done = alloc_done; @@ -7008,7 +7007,7 @@ ip_invoke_with_position(argc, argv, obj, position) DUMP2("back from handler (current thread:%lx)", current); /* get result & free allocated memory */ - ret = RARRAY(result)->ptr[0]; + ret = RARRAY_PTR(result)[0]; free(alloc_done); Tcl_Release(ivq); @@ -7535,11 +7534,9 @@ lib_split_tklist_core(ip_obj, list_str) for(idx = 0; idx < objc; idx++) { elem = get_str_from_obj(objv[idx]); if (taint_flag) OBJ_TAINT(elem); - RARRAY(ary)->ptr[idx] = elem; + rb_ary_push(ary, elem); } - RARRAY(ary)->len = objc; - if (old_gc == Qfalse) rb_gc_enable(); rb_thread_critical = thr_crit_bup; @@ -7576,10 +7573,8 @@ lib_split_tklist_core(ip_obj, list_str) elem = rb_str_new2(argv[idx]); } /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */ - RARRAY(ary)->ptr[idx] = elem; + rb_ary_push(ary, elem); } - RARRAY(ary)->len = argc; - if (old_gc == Qfalse) rb_gc_enable(); #endif } |