From 0d5509eb49d621060b8aef6373628a0017faaff0 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 5 Jan 2011 09:47:09 +0000 Subject: Split the flags and argc parameters to S_tied_handle_method(). Previously they were combined into one numeric value, using a bitshift. This was a false economy. --- pp_sys.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'pp_sys.c') diff --git a/pp_sys.c b/pp_sys.c index 57e4730228..3dac68befc 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -512,19 +512,17 @@ PP(pp_die) architecture can generate more efficient instructions. */ #define MORTALIZE_NOT_NEEDED 0x04 #define ARGUMENTS_ON_STACK 0x08 -#define TIED_HANDLE_ARGC_SHIFT 4 static OP * S_tied_handle_method(pTHX_ const char *const methname, SV **sp, - IO *const io, MAGIC *const mg, const U32 flags, ...) + IO *const io, MAGIC *const mg, const U32 flags, U32 argc, + ...) { - U32 argc = flags >> TIED_HANDLE_ARGC_SHIFT; - PERL_ARGS_ASSERT_TIED_HANDLE_METHOD; /* Ensure that our flag bits do not overlap. */ assert((MORTALIZE_NOT_NEEDED & G_WANT) == 0); - assert((G_WANT >> TIED_HANDLE_ARGC_SHIFT) == 0); + assert((ARGUMENTS_ON_STACK & G_WANT) == 0); PUSHMARK(sp); PUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); @@ -533,7 +531,7 @@ S_tied_handle_method(pTHX_ const char *const methname, SV **sp, else if (argc) { const U32 mortalize_not_needed = flags & MORTALIZE_NOT_NEEDED; va_list args; - va_start(args, flags); + va_start(args, argc); do { SV *const arg = va_arg(args, SV *); if(mortalize_not_needed) @@ -552,11 +550,11 @@ S_tied_handle_method(pTHX_ const char *const methname, SV **sp, } #define tied_handle_method(a,b,c,d) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,0) #define tied_handle_method1(a,b,c,d,e) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR | (1 << TIED_HANDLE_ARGC_SHIFT),e) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,1,e) #define tied_handle_method2(a,b,c,d,e,f) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR | (2 << TIED_HANDLE_ARGC_SHIFT), e,f) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,2,e,f) PP(pp_open) { @@ -588,8 +586,8 @@ PP(pp_open) /* Method's args are same as ours ... */ /* ... except handle is replaced by the object */ return S_tied_handle_method(aTHX_ "OPEN", mark - 1, io, mg, - G_SCALAR | ARGUMENTS_ON_STACK - | (sp - mark) << TIED_HANDLE_ARGC_SHIFT); + G_SCALAR | ARGUMENTS_ON_STACK, + sp - mark); } } @@ -780,10 +778,8 @@ PP(pp_binmode) figure out. Although, as it's a static function, in theory it could. */ return S_tied_handle_method(aTHX_ "BINMODE", SP, io, mg, - G_SCALAR|MORTALIZE_NOT_NEEDED - | (discp - ? (1 << TIED_HANDLE_ARGC_SHIFT) : 0), - discp); + G_SCALAR|MORTALIZE_NOT_NEEDED, + discp ? 1 : 0, discp); } } @@ -1265,7 +1261,7 @@ PP(pp_getc) MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { const U32 gimme = GIMME_V; - S_tied_handle_method(aTHX_ "GETC", SP, io, mg, gimme); + S_tied_handle_method(aTHX_ "GETC", SP, io, mg, gimme, 0); if (gimme == G_SCALAR) { SPAGAIN; SvSetMagicSV_nosteal(TARG, TOPs); @@ -1512,8 +1508,8 @@ PP(pp_prtf) ++SP; } return S_tied_handle_method(aTHX_ "PRINTF", mark - 1, io, mg, - G_SCALAR | ARGUMENTS_ON_STACK - | (sp - mark) << TIED_HANDLE_ARGC_SHIFT); + G_SCALAR | ARGUMENTS_ON_STACK, + sp - mark); } } @@ -1604,8 +1600,8 @@ PP(pp_sysread) MAGIC *const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { return S_tied_handle_method(aTHX_ "READ", mark - 1, io, mg, - G_SCALAR | ARGUMENTS_ON_STACK - | (sp - mark) << TIED_HANDLE_ARGC_SHIFT); + G_SCALAR | ARGUMENTS_ON_STACK, + sp - mark); } } @@ -1849,8 +1845,8 @@ PP(pp_send) } return S_tied_handle_method(aTHX_ "WRITE", mark - 1, io, mg, - G_SCALAR | ARGUMENTS_ON_STACK - | (sp - mark) << TIED_HANDLE_ARGC_SHIFT); + G_SCALAR | ARGUMENTS_ON_STACK, + sp - mark); } } if (!gv) -- cgit v1.2.1