summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-03-23 23:32:19 +0000
committerNicholas Clark <nick@ccl4.org>2007-03-23 23:32:19 +0000
commita86a1ca71b6cc69a4a01c17f91f95d556810d9f3 (patch)
tree4cf05668194857f3c6b266ce41b4f59e5306cf4a
parent947077407b91d1804ad3931bbfee74e90819e636 (diff)
downloadperl-a86a1ca71b6cc69a4a01c17f91f95d556810d9f3.tar.gz
It's possible to write the dup of struct reg_substr_datum with a
memcpy() replacing the member by member copy. Curiously gcc's -Os produces the same sized code, but not all optimisers may manage this. Also, by reading and re-assigning to the copied data for the sv_dup()s we hope to avoid any cache misses on the copied from data. p4raw-id: //depot/perl@30740
-rw-r--r--regcomp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/regcomp.c b/regcomp.c
index 8b8cec4922..9aa6872c15 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -8903,8 +8903,7 @@ Perl_re_dup(pTHX_ const regexp *r, CLONE_PARAMS *param)
{
dVAR;
regexp *ret;
- I32 i, npar;
- struct reg_substr_datum *s;
+ I32 npar;
if (!r)
return (REGEXP *)NULL;
@@ -8929,14 +8928,20 @@ Perl_re_dup(pTHX_ const regexp *r, CLONE_PARAMS *param)
}
if (r->substrs) {
+ struct reg_substr_datum *s;
+ const struct reg_substr_datum *s_end;
+
Newx(ret->substrs, 1, struct reg_substr_data);
- for (s = ret->substrs->data, i = 0; i < 3; i++, s++) {
- s->min_offset = r->substrs->data[i].min_offset;
- s->max_offset = r->substrs->data[i].max_offset;
- s->end_shift = r->substrs->data[i].end_shift;
- s->substr = sv_dup_inc(r->substrs->data[i].substr, param);
- s->utf8_substr = sv_dup_inc(r->substrs->data[i].utf8_substr, param);
- }
+ StructCopy(r->substrs, ret->substrs, struct reg_substr_data);
+
+ s = ret->substrs->data;
+ s_end
+ = s + sizeof(ret->substrs->data) / sizeof(struct reg_substr_datum);
+
+ do {
+ s->substr = sv_dup_inc(s->substr, param);
+ s->utf8_substr = sv_dup_inc(s->utf8_substr, param);
+ } while (++s < s_end);
} else
ret->substrs = NULL;