[svn:parrot] r39449 - trunk/src/pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Mon Jun 8 09:10:09 UTC 2009
Author: chromatic
Date: Mon Jun 8 09:10:08 2009
New Revision: 39449
URL: https://trac.parrot.org/parrot/changeset/39449
Log:
[PMC] Avoided unnecessary STRING copying in emit() and lineno() methods by
using String PMC attributes directly -- as CodeString extends String, this is
safe.
Avoided mostly unnecessary calls to string_ord() to coalesce \r\n sequence into a single logical newline.
This combination speeds up Rakudo's actions.pm processing by 2.61%.
Modified:
trunk/src/pmc/codestring.pmc
Modified: trunk/src/pmc/codestring.pmc
==============================================================================
--- trunk/src/pmc/codestring.pmc Mon Jun 8 01:36:22 2009 (r39448)
+++ trunk/src/pmc/codestring.pmc Mon Jun 8 09:10:08 2009 (r39449)
@@ -128,7 +128,8 @@
if ('\n' != Parrot_str_indexed(INTERP, fmt, Parrot_str_byte_length(interp, fmt) - 1))
fmt = Parrot_str_concat(INTERP, fmt, newline, 0);
- S1 = Parrot_str_concat(INTERP, SELF.get_string(), fmt, 0);
+ GET_ATTR_str_val(INTERP, SELF, S1);
+ S1 = Parrot_str_concat(INTERP, S1, fmt, 0);
VTABLE_set_string_native(INTERP, SELF, S1);
RETURN(PMC *SELF);
@@ -168,17 +169,22 @@
ipos = last_pos;
}
- str = SELF.get_string();
+ GET_ATTR_str_val(INTERP, SELF, str);
jpos = Parrot_str_find_cclass(INTERP, enum_cclass_newline, str, ipos, pos);
while (jpos < pos) {
- line++;
+
+ if (ipos
+ && jpos == ipos
+ && string_ord(INTERP, str, jpos) == 10
+ && string_ord(INTERP, str, ipos - 1) == 13) {
+ /* do not increment line; \r\n is a single line separator */
+ }
+ else
+ line++;
ipos = jpos + 1;
- /* treat \r\n as a single line separator */
- ipos += (string_ord(INTERP, str, jpos) == 13
- && string_ord(INTERP, str, jpos + 1) == 10);
jpos = Parrot_str_find_cclass(INTERP, enum_cclass_newline, str, ipos, pos);
}
More information about the parrot-commits
mailing list