[svn:parrot] r46184 - branches/codestring/src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Fri Apr 30 06:48:29 UTC 2010
Author: coke
Date: Fri Apr 30 06:48:29 2010
New Revision: 46184
URL: https://trac.parrot.org/parrot/changeset/46184
Log:
Small optimization - if the whole string is %-free, avoid a substr call.
tewk++ for pointing this out.
tewk++ as this seems to fix the buffer leak in the simple case.
Modified:
branches/codestring/src/pmc/codestring.pmc
Modified: branches/codestring/src/pmc/codestring.pmc
==============================================================================
--- branches/codestring/src/pmc/codestring.pmc Fri Apr 30 06:46:29 2010 (r46183)
+++ branches/codestring/src/pmc/codestring.pmc Fri Apr 30 06:48:29 2010 (r46184)
@@ -127,10 +127,15 @@
percentPos = Parrot_str_find_index(INTERP, fmt, percent, pos);
if (percentPos < 0) {
- /* remaining string can be added as is. */
- VTABLE_push_string(INTERP, strings,
- Parrot_str_substr(INTERP, fmt, pos,
- Parrot_str_byte_length(INTERP, fmt) -pos));
+ if (pos == 0) {
+ VTABLE_push_string(INTERP, strings, fmt);
+ }
+ else {
+ /* remaining string can be added as is. */
+ VTABLE_push_string(INTERP, strings,
+ Parrot_str_substr(INTERP, fmt, pos,
+ Parrot_str_byte_length(INTERP, fmt) -pos));
+ }
break;
}
else {
More information about the parrot-commits
mailing list