Skip to content

Commit 3e0cb5d

Browse files
ruzFather Chrysostomos
authored and
Father Chrysostomos
committed
change tied_method to use SVs with precomputed hash values
1 parent 36925d9 commit 3e0cb5d

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

embed.fnc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ sR |int |dooneliner |NN const char *cmd|NN const char *filename
19601960
# endif
19611961
s |SV * |space_join_names_mortal|NN char *const *array
19621962
#endif
1963-
p |OP * |tied_method|NN const char *const methname|NN SV **sp \
1963+
p |OP * |tied_method|NN SV *methname|NN SV **sp \
19641964
|NN SV *const sv|NN const MAGIC *const mg \
19651965
|const U32 flags|U32 argc|...
19661966

pp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4902,7 +4902,7 @@ PP(pp_splice)
49024902
const MAGIC * const mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied);
49034903

49044904
if (mg) {
4905-
return Perl_tied_method(aTHX_ "SPLICE", mark - 1, MUTABLE_SV(ary), mg,
4905+
return Perl_tied_method(aTHX_ SV_CONST(SPLICE), mark - 1, MUTABLE_SV(ary), mg,
49064906
GIMME_V | TIED_METHOD_ARGUMENTS_ON_STACK,
49074907
sp - mark);
49084908
}
@@ -5100,7 +5100,7 @@ PP(pp_push)
51005100
PUSHMARK(MARK);
51015101
PUTBACK;
51025102
ENTER_with_name("call_PUSH");
5103-
call_method("PUSH",G_SCALAR|G_DISCARD|G_METHOD_NAMED);
5103+
call_sv(SV_CONST(PUSH),G_SCALAR|G_DISCARD|G_METHOD_NAMED);
51045104
LEAVE_with_name("call_PUSH");
51055105
SPAGAIN;
51065106
}

pp_hot.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ PP(pp_print)
783783
Move(MARK, MARK + 1, (SP - MARK) + 1, SV*);
784784
++SP;
785785
}
786-
return Perl_tied_method(aTHX_ "PRINT", mark - 1, MUTABLE_SV(io),
786+
return Perl_tied_method(aTHX_ SV_CONST(PRINT), mark - 1, MUTABLE_SV(io),
787787
mg,
788788
(G_SCALAR | TIED_METHOD_ARGUMENTS_ON_STACK
789789
| (PL_op->op_type == OP_SAY
@@ -1658,7 +1658,7 @@ Perl_do_readline(pTHX)
16581658
if (io) {
16591659
const MAGIC *const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
16601660
if (mg) {
1661-
Perl_tied_method(aTHX_ "READLINE", SP, MUTABLE_SV(io), mg, gimme, 0);
1661+
Perl_tied_method(aTHX_ SV_CONST(READLINE), SP, MUTABLE_SV(io), mg, gimme, 0);
16621662
if (gimme == G_SCALAR) {
16631663
SPAGAIN;
16641664
SvSetSV_nosteal(TARG, TOPs);

pp_sys.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ PP(pp_die)
528528
/* I/O. */
529529

530530
OP *
531-
Perl_tied_method(pTHX_ const char *const methname, SV **sp, SV *const sv,
531+
Perl_tied_method(pTHX_ SV *methname, SV **sp, SV *const sv,
532532
const MAGIC *const mg, const U32 flags, U32 argc, ...)
533533
{
534534
SV **orig_sp = sp;
@@ -572,7 +572,7 @@ Perl_tied_method(pTHX_ const char *const methname, SV **sp, SV *const sv,
572572
SAVEGENERICSV(PL_ors_sv);
573573
PL_ors_sv = newSVpvs("\n");
574574
}
575-
ret_args = call_method(methname, flags & G_WANT);
575+
ret_args = call_sv(methname, (flags & G_WANT)|G_METHOD_NAMED);
576576
SPAGAIN;
577577
orig_sp = sp;
578578
POPSTACK;
@@ -623,7 +623,7 @@ PP(pp_open)
623623
if (mg) {
624624
/* Method's args are same as ours ... */
625625
/* ... except handle is replaced by the object */
626-
return Perl_tied_method(aTHX_ "OPEN", mark - 1, MUTABLE_SV(io), mg,
626+
return Perl_tied_method(aTHX_ SV_CONST(OPEN), mark - 1, MUTABLE_SV(io), mg,
627627
G_SCALAR | TIED_METHOD_ARGUMENTS_ON_STACK,
628628
sp - mark);
629629
}
@@ -662,7 +662,7 @@ PP(pp_close)
662662
if (io) {
663663
const MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
664664
if (mg) {
665-
return tied_method0("CLOSE", SP, MUTABLE_SV(io), mg);
665+
return tied_method0(SV_CONST(CLOSE), SP, MUTABLE_SV(io), mg);
666666
}
667667
}
668668
}
@@ -745,7 +745,7 @@ PP(pp_fileno)
745745
if (io
746746
&& (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar)))
747747
{
748-
return tied_method0("FILENO", SP, MUTABLE_SV(io), mg);
748+
return tied_method0(SV_CONST(FILENO), SP, MUTABLE_SV(io), mg);
749749
}
750750

751751
if (!io || !(fp = IoIFP(io))) {
@@ -816,7 +816,7 @@ PP(pp_binmode)
816816
function, which I don't think that the optimiser will be able to
817817
figure out. Although, as it's a static function, in theory it
818818
could. */
819-
return Perl_tied_method(aTHX_ "BINMODE", SP, MUTABLE_SV(io), mg,
819+
return Perl_tied_method(aTHX_ SV_CONST(BINMODE), SP, MUTABLE_SV(io), mg,
820820
G_SCALAR|TIED_METHOD_MORTALIZE_NOT_NEEDED,
821821
discp ? 1 : 0, discp);
822822
}
@@ -1298,7 +1298,7 @@ PP(pp_getc)
12981298
const MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
12991299
if (mg) {
13001300
const U32 gimme = GIMME_V;
1301-
Perl_tied_method(aTHX_ "GETC", SP, MUTABLE_SV(io), mg, gimme, 0);
1301+
Perl_tied_method(aTHX_ SV_CONST(GETC), SP, MUTABLE_SV(io), mg, gimme, 0);
13021302
if (gimme == G_SCALAR) {
13031303
SPAGAIN;
13041304
SvSetMagicSV_nosteal(TARG, TOPs);
@@ -1535,7 +1535,7 @@ PP(pp_prtf)
15351535
Move(MARK, MARK + 1, (SP - MARK) + 1, SV*);
15361536
++SP;
15371537
}
1538-
return Perl_tied_method(aTHX_ "PRINTF", mark - 1, MUTABLE_SV(io),
1538+
return Perl_tied_method(aTHX_ SV_CONST(PRINTF), mark - 1, MUTABLE_SV(io),
15391539
mg,
15401540
G_SCALAR | TIED_METHOD_ARGUMENTS_ON_STACK,
15411541
sp - mark);
@@ -1624,7 +1624,7 @@ PP(pp_sysread)
16241624
{
16251625
const MAGIC *const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
16261626
if (mg) {
1627-
return Perl_tied_method(aTHX_ "READ", mark - 1, MUTABLE_SV(io), mg,
1627+
return Perl_tied_method(aTHX_ SV_CONST(READ), mark - 1, MUTABLE_SV(io), mg,
16281628
G_SCALAR | TIED_METHOD_ARGUMENTS_ON_STACK,
16291629
sp - mark);
16301630
}
@@ -1862,7 +1862,7 @@ PP(pp_syswrite)
18621862
PUTBACK;
18631863
}
18641864

1865-
return Perl_tied_method(aTHX_ "WRITE", mark - 1, MUTABLE_SV(io), mg,
1865+
return Perl_tied_method(aTHX_ SV_CONST(WRITE), mark - 1, MUTABLE_SV(io), mg,
18661866
G_SCALAR | TIED_METHOD_ARGUMENTS_ON_STACK,
18671867
sp - mark);
18681868
}
@@ -2075,7 +2075,7 @@ PP(pp_eof)
20752075
RETPUSHNO;
20762076

20772077
if ((io = GvIO(gv)) && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar))) {
2078-
return tied_method1("EOF", SP, MUTABLE_SV(io), mg, newSVuv(which));
2078+
return tied_method1(SV_CONST(EOF), SP, MUTABLE_SV(io), mg, newSVuv(which));
20792079
}
20802080

20812081
if (!MAXARG && (PL_op->op_flags & OPf_SPECIAL)) { /* eof() */
@@ -2115,7 +2115,7 @@ PP(pp_tell)
21152115
if (io) {
21162116
const MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
21172117
if (mg) {
2118-
return tied_method0("TELL", SP, MUTABLE_SV(io), mg);
2118+
return tied_method0(SV_CONST(TELL), SP, MUTABLE_SV(io), mg);
21192119
}
21202120
}
21212121
else if (!gv) {
@@ -2155,7 +2155,7 @@ PP(pp_sysseek)
21552155
SV *const offset_sv = newSViv(offset);
21562156
#endif
21572157

2158-
return tied_method2("SEEK", SP, MUTABLE_SV(io), mg, offset_sv,
2158+
return tied_method2(SV_CONST(SEEK), SP, MUTABLE_SV(io), mg, offset_sv,
21592159
newSViv(whence));
21602160
}
21612161
}

proto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4543,7 +4543,7 @@ PERL_CALLCONV void Perl_taint_proper(pTHX_ const char* f, const char *const s)
45434543
#define PERL_ARGS_ASSERT_TAINT_PROPER \
45444544
assert(s)
45454545

4546-
PERL_CALLCONV OP * Perl_tied_method(pTHX_ const char *const methname, SV **sp, SV *const sv, const MAGIC *const mg, const U32 flags, U32 argc, ...)
4546+
PERL_CALLCONV OP * Perl_tied_method(pTHX_ SV *methname, SV **sp, SV *const sv, const MAGIC *const mg, const U32 flags, U32 argc, ...)
45474547
__attribute__nonnull__(pTHX_1)
45484548
__attribute__nonnull__(pTHX_2)
45494549
__attribute__nonnull__(pTHX_3)

0 commit comments

Comments
 (0)