summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorBen Tilly <ben_tilly@operamail.com>2000-07-15 13:23:27 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2000-07-24 03:11:52 +0000
commit18ef8beac527ca204cb2b7f96c5a4c585c8ee174 (patch)
tree306e62aa9b2f7b88f567a85fe2e1d8e3ce578880 /pp_ctl.c
parent544f31531e7cbe3b4e7571d94c56f36d53f647fa (diff)
downloadperl-18ef8beac527ca204cb2b7f96c5a4c585c8ee174.tar.gz
Add an optimization for map-maps-a-list-element-to-more-list-elements
case, but add also notes explaining the relationship of this patch and the earlier notes by Sarathy. Subject: Map is still slow Message-ID: <20000715212327.21656.qmail@hotmail.com> p4raw-id: //depot/perl@6429
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 75673dc50f..776754e61c 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -742,7 +742,7 @@ PP(pp_mapwhile)
* is repeatedly extended for every set of items. Is possible
* to do this without any stack extension or copying at all
* by maintaining a separate list over which the map iterates
- * (like foreach does). */
+ * (like foreach does). --gsar */
/* everything in the stack after the destination list moves
* towards the end the stack by the amount of room needed */
@@ -750,6 +750,17 @@ PP(pp_mapwhile)
/* items to shift up (accounting for the moved source pointer) */
count = (SP - PL_stack_base) - (PL_markstack_ptr[-1] - 1);
+
+ /* This optimization is by Ben Tilly and it does
+ * things differently from what Sarathy (gsar)
+ * is describing. The downside of this optimization is
+ * that leaves "holes" (uninitialized and hopefully unused areas)
+ * to the Perl stack, but on the other hand this
+ * shouldn't be a problem. If Sarathy's idea gets
+ * implemented, this optimization should become
+ * irrelevant. --jhi */
+ if (shift < count)
+ shift = count; /* Avoid shifting too often --Ben Tilly */
EXTEND(SP,shift);
src = SP;