[svn:parrot] r46372 - trunk/src/pmc

coke at svn.parrot.org coke at svn.parrot.org
Thu May 6 22:21:59 UTC 2010


Author: coke
Date: Thu May  6 22:21:58 2010
New Revision: 46372
URL: https://trac.parrot.org/parrot/changeset/46372

Log:
small refactor.

Modified:
   trunk/src/pmc/stringbuilder.pmc

Modified: trunk/src/pmc/stringbuilder.pmc
==============================================================================
--- trunk/src/pmc/stringbuilder.pmc	Thu May  6 21:23:24 2010	(r46371)
+++ trunk/src/pmc/stringbuilder.pmc	Thu May  6 22:21:58 2010	(r46372)
@@ -265,14 +265,16 @@
 {
     ASSERT_ARGS(calculate_capacity)
     size_t total_size = current + additional;
+    size_t chunk_size = 1024*1024;
+
     if (total_size < 1024)
-        total_size = (total_size / 128 + 1) * 128;
+        chunk_size = 128;
     else if (total_size < 4096)
-        total_size = (total_size / 1024 + 1) * 1024;
+        chunk_size = 1024;
     else if (total_size < 1024*1024)
-        total_size = (total_size / 4096 + 1) * 4096;
-    else
-        total_size = (total_size / 1024 / 1024 + 1) * 1024 * 1024;
+        chunk_size = 4096;
+
+    total_size = (total_size / chunk_size + 1) * chunk_size;
 
     return total_size;
 }


More information about the parrot-commits mailing list