Hi,

In message "[Clenup?] rb_str_replace"
    on 02/08/29, Michal Rokos <m.rokos / sh.cvut.cz> writes:

|	condition FL_TEST(str2, ELTS_SHARED|STR_ASSOC) is allway true,
|	because FL_TEST(str2, ELTS_SHARED) is already true.
|
|	Is the cleanup really so easy? Or I'm missing something (as
|	usual :-))

Thank you for finding.  Probably we need this too.

|--- string.c	2002/08/28 08:05:23	1.115
|+++ string.c	2002/08/28 15:43:13
|@@ -1603,25 +1603,20 @@ rb_str_replace(str, str2)
|     if (str == str2) return str;
| 
|     StringValue(str2);
|     if (FL_TEST(str2, ELTS_SHARED)) {
| 	if (str_independent(str)) {
| 	    free(RSTRING(str)->ptr);
| 	}
| 	RSTRING(str)->len = RSTRING(str2)->len;
| 	RSTRING(str)->ptr = RSTRING(str2)->ptr;
|-	if (FL_TEST(str2, ELTS_SHARED|STR_ASSOC)) {
|-	    FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
|-	    RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
|-	}
|-	else {
|-	    RSTRING(str)->aux.capa = RSTRING(str2)->aux.capa;
|-	}
|+	FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
|+	RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
|     }
|     else {
| 	rb_str_modify(str);
| 	rb_str_resize(str, RSTRING(str2)->len);
| 	memcpy(RSTRING(str)->ptr, RSTRING(str2)->ptr, RSTRING(str2)->len);
+	if (FL_TEST(str2, STR_ASSOC)) {
+	    FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
+	    RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
+	}
|     }
| 
|     OBJ_INFECT(str, str2);
|     return str;
|-- 

							matz.