Skip to content

Commit ebbae0a

Browse files
committed
op.h: Remove some code duplication
There are two sets of macros here, the raw version does no checking; and the non-raw, which does. Instead of duplicating the complicated expressions, use the raw version inside the non-raw one to make it a bit easier to read
1 parent 41c8453 commit ebbae0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

op.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ struct pmop {
304304
* processing or asserts */
305305
#ifdef USE_ITHREADS
306306
#define PM_GETRE_raw(o) (REGEXP*)(PL_regex_pad[(o)->op_pmoffset])
307-
#define PM_GETRE(o) (SvTYPE(PL_regex_pad[(o)->op_pmoffset]) == SVt_REGEXP \
308-
? (REGEXP*)(PL_regex_pad[(o)->op_pmoffset]) : NULL)
307+
#define PM_GETRE(o) (SvTYPE(PM_GETRE_raw(o)) == SVt_REGEXP \
308+
? PM_GETRE_raw(o) : NULL)
309309

310-
#define PM_SETRE_raw(o,r) STMT_START { \
311-
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(r); \
312-
} STMT_END
310+
#define PM_SETRE_raw(o,r) STMT_START { \
311+
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(r);\
312+
} STMT_END
313313
/* The assignment is just to enforce type safety (or at least get a warning).
314314
*/
315315
/* With first class regexps not via a reference one needs to assign
@@ -321,13 +321,13 @@ struct pmop {
321321
#define PM_SETRE(o,r) STMT_START { \
322322
REGEXP *const pm_setre_ = (r); \
323323
assert(pm_setre_); \
324-
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(pm_setre_); \
324+
PM_SETRE_raw(o, pm_setre_); \
325325
} STMT_END
326326
#else
327327
#define PM_GETRE_raw(o) ((o)->op_pmregexp)
328-
#define PM_GETRE(o) ((o)->op_pmregexp)
328+
#define PM_GETRE(o) PM_GETRE_raw(o)
329329
#define PM_SETRE_raw(o,r) ((o)->op_pmregexp = (r))
330-
#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))
330+
#define PM_SETRE(o,r) PM_SETRE_raw(o,r)
331331
#endif
332332

333333
/* Currently these PMf flags occupy a single 32-bit word. Not all bits are

0 commit comments

Comments
 (0)