[svn:parrot] r46163 - branches/codestring/src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Fri Apr 30 01:03:29 UTC 2010
Author: coke
Date: Fri Apr 30 01:03:29 2010
New Revision: 46163
URL: https://trac.parrot.org/parrot/changeset/46163
Log:
Whoops, checked wrong variable.
Don't create a new RSA when caching, just reusing the existing one.
'make test' now at 100%
Modified:
branches/codestring/src/pmc/codestring.pmc
Modified: branches/codestring/src/pmc/codestring.pmc
==============================================================================
--- branches/codestring/src/pmc/codestring.pmc Fri Apr 30 00:58:56 2010 (r46162)
+++ branches/codestring/src/pmc/codestring.pmc Fri Apr 30 01:03:29 2010 (r46163)
@@ -125,11 +125,10 @@
*/
while (pos >= 0) {
-
/* Find the next % */
percentPos = Parrot_str_find_index(INTERP, fmt, percent, pos);
- if (pos < 0) {
+ if (percentPos < 0) {
/* remaining string can be added as is. */
VTABLE_push_string(INTERP, strings,
Parrot_str_substr(INTERP, fmt, pos,
@@ -149,7 +148,6 @@
/* key is always a single character */
key = Parrot_str_substr(INTERP, fmt, pos++, 1);
-
if (VTABLE_exists_keyed_str(INTERP, hash, key)) {
VTABLE_push_string(INTERP, strings,
VTABLE_get_string_keyed_str(INTERP, hash, key)
@@ -194,8 +192,7 @@
VTABLE_push_string(INTERP, strings, newline);
RETURN(PMC *SELF);
- }
-
+}
/*
@@ -210,12 +207,15 @@
VTABLE STRING *get_string() {
PMC *strings;
- STRING * const empty = CONST_STRING(INTERP, "");
+ INTVAL elements;
STRING *result;
+
GET_ATTR_strings(INTERP, SELF, strings);
+ elements = VTABLE_elements(INTERP, strings);
- result = Parrot_str_join(INTERP, empty, strings);
- /* cache the result */
+ result = Parrot_str_join(INTERP, CONST_STRING(INTERP, ""), strings);
+
+ /* cache the result to avoid a join the next time. */
SELF.set_string_native(result);
return result;
@@ -225,7 +225,7 @@
=item set_string_native()
-Stringify ourselves.
+Save the value both in our string builder and our string-val attribute.
=cut
@@ -233,12 +233,14 @@
VTABLE void set_string_native(STRING *value) {
- PMC *strings = pmc_new(INTERP, enum_class_ResizableStringArray);
+ PMC *strings;
+ GET_ATTR_strings(INTERP, SELF, strings);
+
+ /* cache the result in our StringBuilder */
+ VTABLE_set_integer_native(INTERP, strings, 0);
VTABLE_push_string(INTERP, strings, value);
- SET_ATTR_strings(INTERP, SELF, strings);
}
-
/*
=item lineof(INTVAL pos)
More information about the parrot-commits
mailing list