From c7d4be3fbcd999f77a3cfa0dd21f347053939ea3 Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Sat, 13 Nov 2010 21:02:24 +0000 Subject: [PATCH] Regex's Range changed from class to struct. This change reduces unnecessary memory allocation --- std/regex.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/regex.d b/std/regex.d index 89f0e6480..78dab4a94 100644 --- a/std/regex.d +++ b/std/regex.d @@ -387,7 +387,7 @@ Returns the number of parenthesized captures case REgoto: { auto bitbuf = new OutBuffer; - auto r = new Range(bitbuf); + auto r = Range(bitbuf); size_t offset = i; if (starrchars(r, prog[i .. prog.length])) { @@ -755,7 +755,7 @@ Returns the number of parenthesized captures return 1; } - class Range + struct Range { uint maxc; uint maxb; @@ -821,7 +821,7 @@ Returns the number of parenthesized captures offset = buf.offset; buf.write(cast(uint)0); // reserve space for length buf.reserve(128 / 8); - auto r = new Range(buf); + auto r = Range(buf); if (op == REnotbit) r.setbit2(0); switch (pattern[p]) @@ -994,7 +994,7 @@ Returns the number of parenthesized captures // Return 1 if success, 0 if we can't build a filter or if there is no // point to one. - bool starrchars(Range r, const(ubyte)[] prog) + bool starrchars(ref Range r, const(ubyte)[] prog) { E c; uint maxc;