From 77656d5b86e99eeb0982f03692a736d0ff042d7a Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Mon, 20 Jan 2014 16:51:31 +0000 Subject: [PATCH] re_intuit_start(): simplify fixed offset_max code Since we now assert that all offsets are non-negative, this code can be simplified a bit. Also, by using HOP3lim() rather than HOP3(), we can remove a trailing conditional. --- regexec.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/regexec.c b/regexec.c index 0278aba..86e7615 100644 --- a/regexec.c +++ b/regexec.c @@ -832,22 +832,17 @@ Perl_re_intuit_start(pTHX_ end_point= HOP3(strend, -end_shift, strbeg); } + /* if the regex is absolutely anchored to the start of the string, + * then check_offset_max represents an upper bound on the string + * where the substr could start */ if (!ml_anch && prog->intflags & PREGf_ANCH - && prog->check_offset_max != SSize_t_MAX) + && prog->check_offset_max != SSize_t_MAX + && start_shift < prog->check_offset_max) { - U8 *p = (U8*)s; - - if (start_shift > 0) - p = start_point; /* don't HOP over chars already HOPed */ - if (p < end_point) - p = HOP3(p, - (prog->check_offset_max - - (start_shift > 0 ? start_shift : 0) - + CHR_SVLEN(check) - (SvTAIL(check) != 0)), - end_point); - if (p < end_point) - end_point = p; + SSize_t off = prog->check_offset_max - start_shift + + CHR_SVLEN(check) - !!SvTAIL(check); + end_point = HOP3lim(start_point, off, end_point); } DEBUG_OPTIMISE_MORE_r({ -- 2.7.4