[svn:parrot] r38994 - trunk/src/pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed May 20 22:27:54 UTC 2009
Author: chromatic
Date: Wed May 20 22:27:54 2009
New Revision: 38994
URL: https://trac.parrot.org/parrot/changeset/38994
Log:
[PMC] Improved the resizing logic in the ResizablePMCArray PMC to avoid
unnecessary reallocations.
Modified:
trunk/src/pmc/resizablepmcarray.pmc
Modified: trunk/src/pmc/resizablepmcarray.pmc
==============================================================================
--- trunk/src/pmc/resizablepmcarray.pmc Wed May 20 22:27:18 2009 (r38993)
+++ trunk/src/pmc/resizablepmcarray.pmc Wed May 20 22:27:54 2009 (r38994)
@@ -69,11 +69,13 @@
}
else {
-
SUPER(size);
PMC_threshold(SELF) = size;
}
}
+ else if (size == PMC_size(SELF)) {
+ return;
+ }
else if (size <= PMC_threshold(SELF)) {
PMC_size(SELF) = size;
@@ -81,7 +83,6 @@
return;
}
else {
-
INTVAL i, cur, needed;
i = cur = PMC_threshold(SELF);
if (cur < 8192)
@@ -92,8 +93,10 @@
cur &= ~0xfff;
}
- PMC_array(SELF) = (PMC **)mem_sys_realloc(PMC_array(SELF),
- cur * sizeof (PMC *));
+ if (cur < 8)
+ cur = 8;
+
+ PMC_array(SELF) = mem_realloc_n_typed(PMC_array(SELF), cur, PMC *);
for (; i < cur; i++) {
(PMC_array(SELF))[i] = PMCNULL;
More information about the parrot-commits
mailing list