[svn:parrot] r45434 - in branches/immutable_strings_part1: compilers/imcc src src/io src/pmc src/string/charset
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed Apr 7 21:16:03 UTC 2010
Author: chromatic
Date: Wed Apr 7 21:16:02 2010
New Revision: 45434
URL: https://trac.parrot.org/parrot/changeset/45434
Log:
Remove a bunch of str_copy usage
Modified:
branches/immutable_strings_part1/compilers/imcc/parser_util.c
branches/immutable_strings_part1/src/hash.c
branches/immutable_strings_part1/src/io/api.c
branches/immutable_strings_part1/src/key.c
branches/immutable_strings_part1/src/library.c
branches/immutable_strings_part1/src/packfile.c
branches/immutable_strings_part1/src/pmc/callcontext.pmc
branches/immutable_strings_part1/src/pmc/class.pmc
branches/immutable_strings_part1/src/pmc/codestring.pmc
branches/immutable_strings_part1/src/pmc/coroutine.pmc
branches/immutable_strings_part1/src/pmc/eventhandler.pmc
branches/immutable_strings_part1/src/pmc/filehandle.pmc
branches/immutable_strings_part1/src/pmc/key.pmc
branches/immutable_strings_part1/src/pmc/namespace.pmc
branches/immutable_strings_part1/src/pmc/packfiledirectory.pmc
branches/immutable_strings_part1/src/pmc/parrotinterpreter.pmc
branches/immutable_strings_part1/src/pmc/pmcproxy.pmc
branches/immutable_strings_part1/src/pmc/role.pmc
branches/immutable_strings_part1/src/pmc/string.pmc
branches/immutable_strings_part1/src/pmc/stringhandle.pmc
branches/immutable_strings_part1/src/pmc/sub.pmc
branches/immutable_strings_part1/src/string/charset/ascii.c
branches/immutable_strings_part1/src/string/charset/iso-8859-1.c
Modified: branches/immutable_strings_part1/compilers/imcc/parser_util.c
==============================================================================
--- branches/immutable_strings_part1/compilers/imcc/parser_util.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/compilers/imcc/parser_util.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -708,7 +708,7 @@
sub_data->seg = new_cs;
sub_data->start_offs = 0;
sub_data->end_offs = new_cs->base.size;
- sub_data->name = Parrot_str_copy(interp, name);
+ sub_data->name = name;
*error_message = NULL;
}
Modified: branches/immutable_strings_part1/src/hash.c
==============================================================================
--- branches/immutable_strings_part1/src/hash.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/hash.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -1414,7 +1414,7 @@
break;
case enum_type_STRING:
- valtmp = (void *)Parrot_str_copy(interp, (STRING *)b->value);
+ valtmp = b->value;
break;
case enum_type_PMC:
Modified: branches/immutable_strings_part1/src/io/api.c
==============================================================================
--- branches/immutable_strings_part1/src/io/api.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/io/api.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -367,7 +367,7 @@
"Cannot read from a closed filehandle");
if (length == 0)
- result = Parrot_str_copy(interp, string_orig);
+ result = string_orig;
else {
INTVAL read_length = length;
const INTVAL orig_length = Parrot_str_byte_length(interp, string_orig);
Modified: branches/immutable_strings_part1/src/key.c
==============================================================================
--- branches/immutable_strings_part1/src/key.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/key.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -444,8 +444,6 @@
{
STRING *s;
GETATTR_Key_str_key(interp, key, s);
- if (s)
- s = Parrot_str_new_COW(interp, s);
return s;
}
case KEY_string_FLAG | KEY_register_FLAG:
Modified: branches/immutable_strings_part1/src/library.c
==============================================================================
--- branches/immutable_strings_part1/src/library.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/library.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -505,7 +505,7 @@
ASSERT_ARGS(path_concat)
STRING* join;
- join = Parrot_str_copy(interp, l_path);
+ join = l_path;
join = path_guarantee_trailing_separator(interp, join);
join = Parrot_str_append(interp, join, r_path);
@@ -532,9 +532,7 @@
ASSERT_ARGS(try_load_path)
STRING *final;
- final = Parrot_str_copy(interp, path);
-
- final = path_finalize(interp, final);
+ final = path_finalize(interp, path);
if (Parrot_stat_info_intval(interp, final, STAT_EXISTS)) {
return final;
@@ -717,8 +715,7 @@
STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i);
STRING *found_name;
- full_name = Parrot_str_copy(interp, path);
- full_name = path_append(interp, full_name, file);
+ full_name = path_append(interp, path, file);
found_name =
(type & PARROT_RUNTIME_FT_DYNEXT)
@@ -929,11 +926,11 @@
}
else if (pos_sl) {
stem = Parrot_str_substr(interp, in, pos_sl, len - pos_sl, NULL, 0);
- *wo_ext = Parrot_str_copy(interp, in);
+ *wo_ext = in;
*ext = NULL;
}
else {
- stem = Parrot_str_copy(interp, in);
+ stem = in;
*wo_ext = stem;
*ext = NULL;
}
Modified: branches/immutable_strings_part1/src/packfile.c
==============================================================================
--- branches/immutable_strings_part1/src/packfile.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/packfile.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -2452,7 +2452,7 @@
self->size = 0;
self->data = NULL;
self->id = 0;
- self->name = Parrot_str_copy(interp, name);
+ self->name = name;
}
Modified: branches/immutable_strings_part1/src/pmc/callcontext.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/callcontext.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/callcontext.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -1429,7 +1429,7 @@
SET_ATTR_type_tuple(INTERP, dest, VTABLE_clone(INTERP, type_tuple));
if (short_sig)
- SET_ATTR_short_sig(INTERP, dest, Parrot_str_copy(INTERP, short_sig));
+ SET_ATTR_short_sig(INTERP, dest, short_sig);
if (!PMC_IS_NULL(arg_flags))
SET_ATTR_arg_flags(INTERP, dest, VTABLE_clone(INTERP, arg_flags));
Modified: branches/immutable_strings_part1/src/pmc/class.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/class.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/class.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -668,7 +668,7 @@
*/
VTABLE STRING *get_string() {
- return Parrot_str_copy(interp, make_class_name(interp, SELF));
+ return make_class_name(interp, SELF);
}
/*
Modified: branches/immutable_strings_part1/src/pmc/codestring.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/codestring.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/codestring.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -112,8 +112,6 @@
INTVAL pos = 0;
INTVAL replen = 0;
- fmt = Parrot_str_new_COW(INTERP, fmt);
-
while (pos >= 0) {
pos += replen;
pos = Parrot_str_find_index(INTERP, fmt, percent, pos);
@@ -134,7 +132,6 @@
INTVAL I1;
repl = VTABLE_get_string_keyed_int(INTERP, args, 0);
- repl = Parrot_str_new_COW(INTERP, repl);
I1 = VTABLE_elements(INTERP, args);
I0 = 1;
@@ -258,8 +255,7 @@
RETURN(STRING *counter_as_string);
}
else {
- STRING *result = Parrot_str_copy(INTERP, format);
- result = Parrot_str_concat(INTERP, result, counter_as_string, 1);
+ STRING *result = Parrot_str_concat(INTERP, format, counter_as_string, 1);
RETURN(STRING *result);
}
}
Modified: branches/immutable_strings_part1/src/pmc/coroutine.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/coroutine.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/coroutine.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -120,9 +120,6 @@
(Parrot_Coroutine_attributes *)PMC_data(SELF),
sizeof (Parrot_Coroutine_attributes));
- GET_ATTR_name(INTERP, ret, name);
- SET_ATTR_name(INTERP, ret, Parrot_str_copy(INTERP, name));
-
return ret;
}
Modified: branches/immutable_strings_part1/src/pmc/eventhandler.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/eventhandler.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/eventhandler.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -167,7 +167,7 @@
Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e)
- return Parrot_str_copy(INTERP, e->type);
+ return e->type;
return string_from_literal(INTERP, "");
}
Modified: branches/immutable_strings_part1/src/pmc/filehandle.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/filehandle.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/filehandle.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -253,10 +253,10 @@
"Cannot reopen already open filehandle");
if (got_mode && !STRING_IS_NULL(mode))
- SET_ATTR_mode(INTERP, SELF, Parrot_str_copy(INTERP, mode));
+ SET_ATTR_mode(INTERP, SELF, mode);
if (got_filename && !STRING_IS_NULL(filename))
- SET_ATTR_filename(INTERP, SELF, Parrot_str_copy(INTERP, filename));
+ SET_ATTR_filename(INTERP, SELF, filename);
/* Open the file. With no options, reopen the same file as before */
GET_ATTR_filename(INTERP, SELF, open_filename);
@@ -619,10 +619,7 @@
METHOD mode() {
STRING *mode, *mode_copy;
-
GET_ATTR_mode(INTERP, SELF, mode);
- mode_copy = Parrot_str_copy(INTERP, mode);
-
RETURN(STRING *mode_copy);
}
@@ -640,19 +637,13 @@
METHOD encoding(STRING *new_encoding :optional, INTVAL got_encoding :opt_flag) {
STRING *encoding;
- STRING *encoding_copy = NULL;
if (got_encoding) {
- if (!STRING_IS_NULL(new_encoding))
- encoding_copy = Parrot_str_copy(INTERP, new_encoding);
- SET_ATTR_encoding(INTERP, SELF, encoding_copy);
+ SET_ATTR_encoding(INTERP, SELF, new_encoding);
RETURN(STRING *new_encoding);
}
GET_ATTR_encoding(INTERP, SELF, encoding);
- if (!STRING_IS_NULL(encoding))
- encoding_copy = Parrot_str_copy(INTERP, encoding);
-
RETURN(STRING *encoding_copy);
}
Modified: branches/immutable_strings_part1/src/pmc/key.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/key.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/key.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -74,8 +74,7 @@
break;
case KEY_string_FLAG:
case KEY_string_FLAG | KEY_register_FLAG:
- key_set_string(INTERP, dkey,
- Parrot_str_copy(INTERP, VTABLE_get_string(INTERP, key)));
+ key_set_string(INTERP, dkey, VTABLE_get_string(INTERP, key));
break;
case KEY_pmc_FLAG:
case KEY_pmc_FLAG | KEY_register_FLAG:
Modified: branches/immutable_strings_part1/src/pmc/namespace.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/namespace.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/namespace.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -158,7 +158,7 @@
if (Parrot_str_equal(interp, sub->method_name, CONST_STRING(interp, ""))) {
if (sub->vtable_index != -1 && vtable_key != NULL) {
- method_name = Parrot_str_copy(interp, vtable_key);
+ method_name = vtable_key;
}
}
else {
Modified: branches/immutable_strings_part1/src/pmc/packfiledirectory.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/packfiledirectory.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/packfiledirectory.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -148,7 +148,7 @@
PackFile_Segment * const pfseg = (PackFile_Segment *)VTABLE_get_pointer(interp, seg);
pfseg->pf = pf;
- pfseg->name = Parrot_str_copy(interp, name);
+ pfseg->name = name;
PackFile_add_segment(interp, pfdir, pfseg);
}
Modified: branches/immutable_strings_part1/src/pmc/parrotinterpreter.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/parrotinterpreter.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/parrotinterpreter.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -145,7 +145,7 @@
Parrot_Class_attributes * const source_class = PARROT_CLASS(source);
Parrot_Class_attributes * const dest_class = PARROT_CLASS(dest);
- dest_class->name = Parrot_str_copy(d, source_class->name);
+ dest_class->name = source_class->name;
dest_class->_namespace = VTABLE_clone(d, source_class->_namespace);
}
}
Modified: branches/immutable_strings_part1/src/pmc/pmcproxy.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/pmcproxy.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/pmcproxy.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -486,9 +486,7 @@
VTABLE STRING *get_string() {
Parrot_Class_attributes * const proxy_info = PARROT_CLASS(SELF);
-
- /* Copy the stored string name of the proxy. */
- return Parrot_str_copy(interp, proxy_info->name);
+ return proxy_info->name;
}
Modified: branches/immutable_strings_part1/src/pmc/role.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/role.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/role.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -515,7 +515,7 @@
}
/* Otherwise, copy the stored string name of the class. */
- return Parrot_str_copy(interp, role->name);
+ return role->name;
}
/*
Modified: branches/immutable_strings_part1/src/pmc/string.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/string.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/string.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -125,8 +125,7 @@
VTABLE STRING *get_string() {
STRING *str_val;
GET_ATTR_str_val(INTERP, SELF, str_val);
-
- return str_val ? Parrot_str_copy(INTERP, str_val) : NULL;
+ return str_val;
}
/*
@@ -217,12 +216,7 @@
*/
VTABLE void assign_string_native(STRING *value) {
- if (!STRING_IS_NULL(value)) {
- SET_ATTR_str_val(INTERP, SELF,
- Parrot_str_set(INTERP, SELF.get_string(), value));
- }
- else
- SET_ATTR_str_val(INTERP, SELF, NULL);
+ SET_ATTR_str_val(INTERP, SELF, value);
}
/*
Modified: branches/immutable_strings_part1/src/pmc/stringhandle.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/stringhandle.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/stringhandle.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -110,11 +110,11 @@
Parrot_StringHandle_attributes * const data_struct = PARROT_STRINGHANDLE(copy);
if (old_struct->stringhandle != NULL)
- data_struct->stringhandle = Parrot_str_copy(INTERP, old_struct->stringhandle);
+ data_struct->stringhandle = old_struct->stringhandle;
if (old_struct->mode != NULL)
- data_struct->mode = Parrot_str_copy(INTERP, old_struct->mode);
+ data_struct->mode = old_struct->mode;
if (old_struct->encoding != NULL)
- data_struct->encoding = Parrot_str_copy(INTERP, old_struct->encoding);
+ data_struct->encoding = old_struct->encoding;
data_struct->flags = old_struct->flags;
return copy;
@@ -182,10 +182,10 @@
INTVAL flags;
if (got_mode && !STRING_IS_NULL(mode))
- SET_ATTR_mode(INTERP, SELF, Parrot_str_copy(INTERP, mode));
+ SET_ATTR_mode(INTERP, SELF, mode);
if (got_filename && !STRING_IS_NULL(filename))
- SET_ATTR_filename(INTERP, SELF, Parrot_str_copy(INTERP, filename));
+ SET_ATTR_filename(INTERP, SELF, filename);
/* If StringHandle hasn't already been initialized, create a new string. */
@@ -317,8 +317,6 @@
else
string_result = Parrot_str_new_constant(INTERP, "");
}
- else
- string_result = Parrot_str_copy(INTERP, string_result);
RETURN(STRING *string_result);
}
@@ -465,12 +463,8 @@
METHOD mode() {
STRING *mode, *mode_copy;
-
GET_ATTR_mode(INTERP, SELF, mode);
- mode_copy = Parrot_str_copy(INTERP, mode);
-
RETURN(STRING *mode_copy);
-
}
/*
@@ -486,21 +480,14 @@
METHOD encoding(STRING *new_encoding :optional, INTVAL got_encoding :opt_flag) {
STRING *encoding;
- STRING *encoding_copy = NULL;
if (got_encoding) {
- if (!STRING_IS_NULL(new_encoding))
- encoding_copy = Parrot_str_copy(INTERP, new_encoding);
- SET_ATTR_encoding(INTERP, SELF, encoding_copy);
+ SET_ATTR_encoding(INTERP, SELF, new_encoding);
RETURN(STRING *new_encoding);
}
GET_ATTR_encoding(INTERP, SELF, encoding);
- if (!STRING_IS_NULL(encoding))
- encoding_copy = Parrot_str_copy(INTERP, encoding);
-
RETURN(STRING *encoding_copy);
-
}
/*
Modified: branches/immutable_strings_part1/src/pmc/sub.pmc
==============================================================================
--- branches/immutable_strings_part1/src/pmc/sub.pmc Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/pmc/sub.pmc Wed Apr 7 21:16:02 2010 (r45434)
@@ -252,20 +252,14 @@
*/
VTABLE STRING *get_string() {
- Parrot_Sub_attributes *sub;
- PMC_get_sub(INTERP, SELF, sub);
-
- if (sub->name)
- return Parrot_str_copy(INTERP, sub->name);
-
- return NULL;
+ STRING *name;
+ GET_ATTR_name(INTERP, SELF, name);
+ return name;
}
VTABLE void set_string_native(STRING *subname) {
- Parrot_Sub_attributes *sub;
- PMC_get_sub(INTERP, SELF, sub);
- sub->name = Parrot_str_copy(INTERP, subname);
+ SET_ATTR_name(INTERP, SELF, subname);
}
@@ -528,9 +522,6 @@
/* first set the sub struct, Parrot_str_copy may cause GC */
*sub = *dest_sub;
- if (sub->name)
- sub->name = Parrot_str_copy(INTERP, sub->name);
-
/* Be sure not to share arg_info. */
dest_sub->arg_info = NULL;
@@ -563,10 +554,6 @@
/* copy the sub struct */
memmove(my_sub, other_sub, sizeof (Parrot_Sub_attributes));
-
- /* copy the name so it's a different string in memory */
- if (my_sub->name)
- my_sub->name = Parrot_str_copy(INTERP, my_sub->name);
}
else
Parrot_ex_throw_from_c_args(INTERP, NULL,
Modified: branches/immutable_strings_part1/src/string/charset/ascii.c
==============================================================================
--- branches/immutable_strings_part1/src/string/charset/ascii.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/string/charset/ascii.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -361,7 +361,7 @@
compose(PARROT_INTERP, ARGIN(STRING *src))
{
ASSERT_ARGS(compose)
- return Parrot_str_copy(interp, src);
+ return src;
}
/* A noop. can't decompose ascii */
@@ -381,7 +381,7 @@
decompose(PARROT_INTERP, ARGMOD(STRING *src))
{
ASSERT_ARGS(decompose)
- return Parrot_str_copy(interp, src);
+ return src;
}
/*
Modified: branches/immutable_strings_part1/src/string/charset/iso-8859-1.c
==============================================================================
--- branches/immutable_strings_part1/src/string/charset/iso-8859-1.c Wed Apr 7 21:15:57 2010 (r45433)
+++ branches/immutable_strings_part1/src/string/charset/iso-8859-1.c Wed Apr 7 21:16:02 2010 (r45434)
@@ -329,7 +329,7 @@
compose(PARROT_INTERP, ARGIN(STRING *src))
{
ASSERT_ARGS(compose)
- return Parrot_str_copy(interp, src);
+ return src;
}
/*
More information about the parrot-commits
mailing list