summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-02-13 08:31:55 +0000
committerNicholas Clark <nick@ccl4.org>2010-05-20 20:55:42 +0100
commit4cf5eae5e58faebb6ae9e68e493cd85343f7a76c (patch)
tree5123e575ff14cbef24c8b705c2d493f5c4a29f89 /dist
parent78b7eff23b1757f7fccef902e7e706080a997e2c (diff)
downloadperl-4cf5eae5e58faebb6ae9e68e493cd85343f7a76c.tar.gz
Change S_ithread_create() params from a single AV* to a pair of SV** pointers.
This saves creating, duplicating and freeing and AV, which is only ever used for an internal calling convention.
Diffstat (limited to 'dist')
-rwxr-xr-xdist/threads/threads.xs31
1 files changed, 19 insertions, 12 deletions
diff --git a/dist/threads/threads.xs b/dist/threads/threads.xs
index 4ce5f693c3..e83da94dcc 100755
--- a/dist/threads/threads.xs
+++ b/dist/threads/threads.xs
@@ -675,10 +675,13 @@ S_ithread_create(
IV stack_size,
int gimme,
int exit_opt,
- AV *params)
+ SV **params_start,
+ SV **params_end)
{
ithread *thread;
ithread *current_thread = S_ithread_get(aTHX);
+ AV *params;
+ SV **array;
#if PERL_VERSION <= 8 && PERL_SUBVERSION <= 7
SV **tmps_tmp = PL_tmps_stack;
@@ -792,8 +795,13 @@ S_ithread_create(
SvREFCNT_inc(sv_dup(init_function, &clone_param));
}
- thread->params = (AV *)sv_dup((SV *)params, &clone_param);
- SvREFCNT_inc_void(thread->params);
+ thread->params = params = newAV();
+ av_extend(params, params_end - params_start - 1);
+ AvFILLp(params) = params_end - params_start - 1;
+ array = AvARRAY(params);
+ while (params_start < params_end) {
+ *array++ = SvREFCNT_inc(sv_dup(*params_start++, &clone_param));
+ }
#if PERL_VERSION <= 8 && PERL_SUBVERSION <= 7
/* The code below checks that anything living on the tmps stack and
@@ -908,7 +916,6 @@ S_ithread_create(
#endif
/* Must unlock mutex for destruct call */
MUTEX_UNLOCK(&MY_POOL.create_destruct_mutex);
- sv_2mortal((SV *)params);
thread->state |= PERL_ITHR_NONVIABLE;
S_ithread_free(aTHX_ thread); /* Releases MUTEX */
#ifndef WIN32
@@ -924,7 +931,6 @@ S_ithread_create(
}
MY_POOL.running_threads++;
- sv_2mortal((SV *)params);
return (thread);
}
@@ -942,7 +948,6 @@ ithread_create(...)
char *classname;
ithread *thread;
SV *function_to_call;
- AV *params;
HV *specs;
IV stack_size;
int context;
@@ -950,7 +955,8 @@ ithread_create(...)
SV *thread_exit_only;
char *str;
int idx;
- int ii;
+ SV **args_start;
+ SV **args_end;
dMY_POOL;
CODE:
if ((items >= 2) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVHV) {
@@ -1050,11 +1056,11 @@ ithread_create(...)
}
/* Function args */
- params = newAV();
+ args_start = &ST(idx + 2);
if (items > 2) {
- for (ii=2; ii < items ; ii++) {
- av_push(params, SvREFCNT_inc(ST(idx+ii)));
- }
+ args_end = &ST(idx + items);
+ } else {
+ args_end = args_start;
}
/* Create thread */
@@ -1063,7 +1069,8 @@ ithread_create(...)
stack_size,
context,
exit_opt,
- params);
+ args_start,
+ args_end);
if (! thread) {
XSRETURN_UNDEF; /* Mutex already unlocked */
}