summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-18 17:23:20 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-18 17:23:20 +0000
commit758fe889107e073a9d7fd63d3f47c18519a0d0ae (patch)
treecac22c6af13c7641c19a821049cf8d75d661ad92
parent226fce73ff7f84d1d58444860a6330114c544ea3 (diff)
downloadpcre-758fe889107e073a9d7fd63d3f47c18519a0d0ae.tar.gz
Put top level heap frame on the stack.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@892 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog6
-rw-r--r--pcre_exec.c14
2 files changed, 13 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index fa91e40..86c8b58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -52,7 +52,11 @@ Version 8.30
13. Applied Dmitry V. Levin's patch for a more portable method for linking with
-lreadline.
-14. ZH added PCRE_CONFIG_JITTARGET; added it's output to pcretest -C.
+14. ZH added PCRE_CONFIG_JITTARGET; added its output to pcretest -C.
+
+15. Applied Graycode's patch to put the top-level frame on the stack rather
+ than the heap when not using the stack for recursion. This gives a
+ performance improvement in many cases when recursion is not deep.
Version 8.21 12-Dec-2011
diff --git a/pcre_exec.c b/pcre_exec.c
index 56af9fc..02f7576 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -332,7 +332,7 @@ argument of match(), which never changes. */
{\
heapframe *oldframe = frame;\
frame = oldframe->Xprevframe;\
- (PUBL(stack_free))(oldframe);\
+ if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
if (frame != NULL)\
{\
rrc = ra;\
@@ -485,13 +485,15 @@ BOOL caseless;
int condcode;
/* When recursion is not being used, all "local" variables that have to be
-preserved over calls to RMATCH() are part of a "frame" which is obtained from
-heap storage. Set up the top-level frame here; others are obtained from the
-heap whenever RMATCH() does a "recursion". See the macro definitions above. */
+preserved over calls to RMATCH() are part of a "frame". We set up the top-level
+frame on the stack here; subsequent instantiations are obtained from the heap
+whenever RMATCH() does a "recursion". See the macro definitions above. Putting
+the top-level on the stack rather than malloc-ing them all gives a performance
+boost in many cases where there is not much "recursion". */
#ifdef NO_RECURSE
-heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));
-if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
+heapframe frame_zero;
+heapframe *frame = &frame_zero;
frame->Xprevframe = NULL; /* Marks the top level */
/* Copy in the original argument variables */