From 3ea8bc937be5cc09bfcc0beabb3ac6c672b01b67 Mon Sep 17 00:00:00 2001 From: Daniel Dragan Date: Tue, 18 Nov 2014 23:08:25 -0500 Subject: [PATCH] remove a branch in SvIV_please_nomg On VC 2003 and GCC 4.6.3, this patch decreases from 3 branches to 2 branches that machine code that makes up SvIV_please_nomg. Functionality should be identical as before. This is intended to make math functions like pp_add faster. Due to complexity/my time, SvIV_please wasn't optimized. "(SvNOK(sv) || SvPOK(sv)" was optimized to "(SvFLAGS(sv) & (SVf_NOK|SVf_POK))" on GCC and VC 2003 before this patch, so that change reenforces what the optimizer already did before. .text section of miniperl.exe size in bytes gcc 32b 4.6.3 -O2 before 0x10d154 gcc 32b 4.6.3 -O2 after 0x10d064 vc2003 before 0xa4odf vc2003 after 0xa406f --- sv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sv.h b/sv.h index 6c77cce..da36705 100644 --- a/sv.h +++ b/sv.h @@ -1313,11 +1313,11 @@ sv_force_normal does nothing. Not guaranteed to stay returning void */ /* Macro won't actually call sv_2iv if already IOK */ #define SvIV_please(sv) \ - STMT_START {if (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv))) \ + STMT_START {if (!SvIOKp(sv) && (SvFLAGS(sv) & (SVf_NOK|SVf_POK))) \ (void) SvIV(sv); } STMT_END #define SvIV_please_nomg(sv) \ - (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv)) \ - ? (SvIV_nomg(sv), SvIOK(sv)) \ + (!(SvFLAGS(sv) & (SVf_IOK|SVp_IOK)) && (SvFLAGS(sv) & (SVf_NOK|SVf_POK)) \ + ? (sv_2iv_flags(sv, 0), SvIOK(sv)) \ : SvIOK(sv)) #define SvIV_set(sv, val) \ STMT_START { \ -- 1.8.3.1