cvsuser 03/07/06 03:26:25
Modified: classes perlscalar.pmc perlstring.pmc
Log:
perlstring cleanup; remove string_copy in concat; use string_set; better morph
Revision Changes Path
1.3 +13 -3 parrot/classes/perlscalar.pmc
Index: perlscalar.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlscalar.pmc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- perlscalar.pmc 23 May 2003 08:02:12 -0000 1.2
+++ perlscalar.pmc 6 Jul 2003 10:26:25 -0000 1.3
@@ -18,11 +18,21 @@
pmclass perlscalar abstract noinit extends scalar {
void morph (INTVAL type) {
+ if (SELF->vtable->base_type == enum_class_PerlString) {
+ if (type == enum_class_PerlString)
+ return;
PObj_custom_mark_CLEAR(SELF);
SELF->vtable = &Parrot_base_vtables[type];
+ return;
+ }
if (type == enum_class_PerlString) {
- PObj_custom_mark_SET(SELF);
+ SELF->vtable = &Parrot_base_vtables[type];
+ DYNSELF.init();
+ return;
}
+ PObj_custom_mark_CLEAR(SELF);
+ SELF->vtable = &Parrot_base_vtables[type];
+
}
}
1.42 +15 -25 parrot/classes/perlstring.pmc
Index: perlstring.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlstring.pmc,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- perlstring.pmc 6 Jul 2003 09:24:10 -0000 1.41
+++ perlstring.pmc 6 Jul 2003 10:26:25 -0000 1.42
@@ -1,7 +1,7 @@
/* perlstring.pmc
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: perlstring.pmc,v 1.41 2003/07/06 09:24:10 leo Exp $
+ * $Id: perlstring.pmc,v 1.42 2003/07/06 10:26:25 leo Exp $
* Overview:
* These are the vtable functions for the PerlString base class
* Data Structure and Algorithms:
@@ -100,15 +100,18 @@
}
void set_string (PMC * value) {
- SELF->cache.string_val = string_copy(INTERP,
(STRING*)value->cache.string_val);
+ SELF->cache.string_val = string_set(INTERP, SELF->cache.string_val,
+ VTABLE_get_string(INTERP, value));
}
void set_string_native (STRING * value) {
- SELF->cache.string_val = string_copy(INTERP, value);
+ SELF->cache.string_val = string_set(INTERP, SELF->cache.string_val,
+ value);
}
void set_string_same (PMC * value) {
- SELF->cache.string_val = string_copy(INTERP,
(STRING*)value->cache.string_val);
+ SELF->cache.string_val = string_set(INTERP, SELF->cache.string_val,
+ value->cache.string_val);
}
/* XXX -lt: only add done yet, others will follow, when
@@ -289,37 +292,23 @@
}
void concatenate (PMC* value, PMC* dest) {
- STRING* s = string_copy(INTERP, (STRING*)SELF->cache.string_val);
+ STRING* s = SELF->cache.string_val;
VTABLE_morph(INTERP, dest, enum_class_PerlString);
dest->cache.string_val =
- string_concat(INTERP,
- s,
- VTABLE_get_string(INTERP, value),
- 0
- );
- /* don't destroy s, as it is dest->cache.string_val */
+ string_concat(INTERP, s, VTABLE_get_string(INTERP, value), 0);
}
void concatenate_native (STRING* value, PMC* dest) {
- STRING* s = string_copy(INTERP, (STRING*)SELF->cache.string_val);
+ STRING* s = SELF->cache.string_val;
VTABLE_morph(INTERP, dest, enum_class_PerlString);
- dest->cache.string_val =
- string_concat(INTERP,
- s,
- value,
- 0
- );
- /* don't destroy s, as it is dest->cache.string_val */
+ dest->cache.string_val = string_concat(INTERP, s, value, 0);
}
void concatenate_same (PMC* value, PMC* dest) {
VTABLE_morph(INTERP, dest, enum_class_PerlString);
dest->cache.string_val =
- string_concat(INTERP,
- SELF->cache.string_val,
- value->cache.string_val,
- 0
- );
+ string_concat(INTERP, SELF->cache.string_val,
+ value->cache.string_val, 0);
}
/* == operation */
@@ -347,7 +336,8 @@
void repeat_int (INTVAL value, PMC* dest) {
DYNSELF.morph(enum_class_PerlString);
VTABLE_morph(INTERP, dest, enum_class_PerlString);
- dest->cache.string_val = string_repeat(INTERP, SELF->cache.string_val,
(UINTVAL)value, NULL);
+ dest->cache.string_val = string_repeat(INTERP,
+ SELF->cache.string_val, (UINTVAL)value, NULL);
}
void increment () {