[svn:parrot] r46313 - branches/codestring/src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Wed May 5 14:40:57 UTC 2010
Author: coke
Date: Wed May 5 14:40:56 2010
New Revision: 46313
URL: https://trac.parrot.org/parrot/changeset/46313
Log:
Give chromatic++ some knobs to tune.
Modified:
branches/codestring/src/pmc/codestring.pmc
Modified: branches/codestring/src/pmc/codestring.pmc
==============================================================================
--- branches/codestring/src/pmc/codestring.pmc Wed May 5 13:58:12 2010 (r46312)
+++ branches/codestring/src/pmc/codestring.pmc Wed May 5 14:40:56 2010 (r46313)
@@ -35,6 +35,9 @@
/* HEADERIZER BEGIN: static */
/* HEADERIZER END: static */
+#define PARROT_CODESTRING_MINIMUM_SIZE 32
+#define PARROT_CODESTRING_COALESCE_THRESHOLD 64
+
pmclass CodeString extends String provides string auto_attrs {
ATTR PMC *linepos; /* start of line positions */
ATTR PMC *strings; /* array of strings... */
@@ -51,8 +54,13 @@
VTABLE void init() {
SET_ATTR_linepos(INTERP, SELF, PMCNULL);
- SET_ATTR_strings(INTERP, SELF, pmc_new(INTERP, enum_class_ResizableStringArray));
+
+ SET_ATTR_strings(INTERP, SELF,
+ Parrot_pmc_new_init_int(INTERP, enum_class_ResizableStringArray,
+ PARROT_CODESTRING_MINIMUM_SIZE));
+
PObj_custom_mark_SET(SELF);
+
}
/*
@@ -186,6 +194,9 @@
if ('\n' != Parrot_str_indexed(INTERP, fmt, Parrot_str_byte_length(INTERP, fmt) - 1))
VTABLE_push_string(INTERP, strings, newline);
+ if (VTABLE_elements(INTERP, strings) > PARROT_CODESTRING_COALESCE_THRESHOLD)
+ SELF.get_string();
+
RETURN(PMC *SELF);
}
@@ -461,6 +472,10 @@
GET_ATTR_strings(INTERP, SELF, strings);
VTABLE_push_string(INTERP, strings, value);
+
+ if (VTABLE_elements(INTERP, strings) > PARROT_CODESTRING_COALESCE_THRESHOLD)
+ SELF.get_string();
+
}
/*
More information about the parrot-commits
mailing list