Skip to content

Commit

Permalink
[pmc] disable 2x StringBuilder.substr clone, GH #1123
Browse files Browse the repository at this point in the history
STRING_substr already creates a copy for us, no need to copy it twice.
no regression.

Note that t/stress/gc.t started failing earlier, even in 7.0.0.
  • Loading branch information
Reini Urban committed Jan 23, 2015
1 parent 0250719 commit fa1bc2c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pmc/stringbuilder.pmc
Expand Up @@ -338,17 +338,17 @@ For testing purpose only?

=item C<VTABLE substr()>

Returns a copied substring of the STRING.

=cut

*/

VTABLE STRING *substr(INTVAL offset, INTVAL length) :no_wb {
VTABLE STRING *substr(INTVAL offset, INTVAL length) { /* note: was ': n o _ w b' */
STRING *buffer;
GET_ATTR_buffer(INTERP, SELF, buffer);
/* We must clone here because we cannot reallocate buffer behind the scene... */
/* TODO Optimize it to avoid creation of redundant STRING [GH #1123] */
return Parrot_str_clone(INTERP,
STRING_substr(INTERP, buffer, offset, length));
/* STRING_substr already creates a copy for us, GH #1123 */
return STRING_substr(INTERP, buffer, offset, length);
}

/*
Expand Down

0 comments on commit fa1bc2c

Please sign in to comment.