summaryrefslogtreecommitdiff
path: root/embed.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-14 17:29:43 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:23 +0100
commit7e8d786b02d3ef1f946a5ac354c2780774902e15 (patch)
treeb69a07af62ca20710fe7794118b2c5e8500737e6 /embed.h
parent12dc5f9406fbb8389be8b9f9406ad247ca07f210 (diff)
downloadperl-7e8d786b02d3ef1f946a5ac354c2780774902e15.tar.gz
optimise (index() == -1)
Unusually, index() and rindex() return -1 on failure. So it's reasonably common to see code like if (index(...) != -1) { ... } and variants. For such code, this commit optimises away to OP_EQ and OP_CONST, and sets a couple of private flags on the index op instead, indicating: OPpTRUEBOOL return a boolean which is a comparison of what the return would have been, against -1 OPpINDEX_BOOLNEG negate the boolean result Its also supports OPpTRUEBOOL in conjunction with the existing OPpTARGET_MY flag, so for example in $lexical = (index(...) == -1) the padmy, sassign, eq and const ops are all optimised away.
Diffstat (limited to 'embed.h')
-rw-r--r--embed.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/embed.h b/embed.h
index 0cdf036e90..15d63bdd4a 100644
--- a/embed.h
+++ b/embed.h
@@ -1171,6 +1171,7 @@
#define ck_delete(a) Perl_ck_delete(aTHX_ a)
#define ck_each(a) Perl_ck_each(aTHX_ a)
#define ck_eof(a) Perl_ck_eof(aTHX_ a)
+#define ck_eq(a) Perl_ck_eq(aTHX_ a)
#define ck_eval(a) Perl_ck_eval(aTHX_ a)
#define ck_exec(a) Perl_ck_exec(aTHX_ a)
#define ck_exists(a) Perl_ck_exists(aTHX_ a)