diff options
author | Nicholas Clark <nick@ccl4.org> | 2003-02-09 23:00:09 +0000 |
---|---|---|
committer | hv <hv@crypt.org> | 2003-02-16 13:10:32 +0000 |
commit | ed25273444c5542e4865fbe422e026b78ba33b80 (patch) | |
tree | 50ed9058a0a221c3334b958f8a0d3b50ed089213 /regexp.h | |
parent | 8c4d3c904bc47216a128a948cce979bf46eb0682 (diff) | |
download | perl-ed25273444c5542e4865fbe422e026b78ba33b80.tar.gz |
COW regexps:
Subject: [PATCH] Copy on write for $& and $1...
Message-ID: <20030209230008.GF299@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@18726
Diffstat (limited to 'regexp.h')
-rw-r--r-- | regexp.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -36,6 +36,9 @@ typedef struct regexp { struct reg_data *data; /* Additional data. */ char *subbeg; /* saved or original string so \digit works forever. */ +#ifdef PERL_COPY_ON_WRITE + SV *saved_copy; /* If non-NULL, SV which is COW from original */ +#endif U32 *offsets; /* offset annotations 20001228 MJD */ I32 sublen; /* Length of string pointed by subbeg */ I32 refcnt; @@ -100,6 +103,23 @@ typedef struct regexp { ? RX_MATCH_COPIED_on(prog) \ : RX_MATCH_COPIED_off(prog)) +#ifdef PERL_COPY_ON_WRITE +#define RX_MATCH_COPY_FREE(rx) \ + STMT_START {if (rx->saved_copy) { \ + SV_CHECK_THINKFIRST_COW_DROP(rx->saved_copy); \ + } \ + if (RX_MATCH_COPIED(rx)) { \ + Safefree(rx->subbeg); \ + RX_MATCH_COPIED_off(rx); \ + }} STMT_END +#else +#define RX_MATCH_COPY_FREE(rx) \ + STMT_START {if (RX_MATCH_COPIED(rx)) { \ + Safefree(rx->subbeg); \ + RX_MATCH_COPIED_off(rx); \ + }} STMT_END +#endif + #define RX_MATCH_UTF8(prog) ((prog)->reganch & ROPT_MATCH_UTF8) #define RX_MATCH_UTF8_on(prog) ((prog)->reganch |= ROPT_MATCH_UTF8) #define RX_MATCH_UTF8_off(prog) ((prog)->reganch &= ~ROPT_MATCH_UTF8) |