Skip to content

Commit 44fa97e

Browse files
committed
FEAT: avoiding series copy where possible (like in append "" 1)
1 parent de38b4b commit 44fa97e

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/core/f-modify.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2022 Rebol Open Source Contributors
6+
** Copyright 2012-2024 Rebol Open Source Contributors
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -180,7 +180,7 @@
180180
src_ser = Form_Tight_Block(src_val);
181181
}
182182
else if (!ANY_STR(src_val) || IS_TAG(src_val)) {
183-
src_ser = Copy_Form_Value(src_val, 0);
183+
src_ser = Form_Value(src_val, 0, FALSE);
184184
}
185185

186186
// Use either new src or the one that was passed:

src/core/n-io.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static REBSER *Read_All_File(char *fname)
116116
**
117117
***********************************************************************/
118118
{
119-
Set_String(D_RET, Copy_Form_Value(D_ARG(1), 0));
119+
Set_String(D_RET, Form_Value(D_ARG(1), 0, TRUE));
120120
return R_RET;
121121
}
122122

@@ -833,7 +833,7 @@ static REBSER *Read_All_File(char *fname)
833833
} else if (ANY_STR(param)) {
834834
argv[i] = Val_Str_To_OS(param);
835835
} else if (IS_WORD(param)) {
836-
Set_Series(REB_STRING, D_RET, Copy_Form_Value(param, TRUE));
836+
Set_Series(REB_STRING, D_RET, Form_Value(param, TRUE, TRUE));
837837
argv[i] = Val_Str_To_OS(D_RET);
838838
} else {
839839
Trap_Arg(param);
@@ -1201,7 +1201,7 @@ static REBSER *Read_All_File(char *fname)
12011201

12021202
Check_Security(SYM_ENVR, POL_READ, arg);
12031203

1204-
if (ANY_WORD(arg)) Set_String(arg, Copy_Form_Value(arg, 0));
1204+
if (ANY_WORD(arg)) Set_String(arg, Form_Value(arg, 0, FALSE));
12051205
cmd = Val_Str_To_OS(arg);
12061206

12071207
lenplus = OS_GET_ENV(cmd, (REBCHR*)0, 0);
@@ -1231,7 +1231,7 @@ static REBSER *Read_All_File(char *fname)
12311231

12321232
Check_Security(SYM_ENVR, POL_WRITE, arg1);
12331233

1234-
if (ANY_WORD(arg1)) Set_String(arg1, Copy_Form_Value(arg1, 0));
1234+
if (ANY_WORD(arg1)) Set_String(arg1, Form_Value(arg1, 0, FALSE));
12351235
cmd = Val_Str_To_OS(arg1);
12361236

12371237
if (ANY_STR(arg2)) {

src/core/s-mold.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ STOID Mold_Error(REBVAL *value, REB_MOLD *mold, REBFLG molded)
14601460

14611461
/***********************************************************************
14621462
**
1463-
*/ REBSER *Copy_Form_Value(REBVAL *value, REBCNT opts)
1463+
*/ REBSER *Form_Value(REBVAL *value, REBCNT opts, REBFLG copy)
14641464
/*
14651465
** Form a value based on the mold opts provided.
14661466
**
@@ -1471,7 +1471,7 @@ STOID Mold_Error(REBVAL *value, REB_MOLD *mold, REBFLG molded)
14711471
mo.opts = opts;
14721472
Reset_Mold(&mo);
14731473
Mold_Value(&mo, value, 0);
1474-
return Copy_String(mo.series, 0, -1);
1474+
return copy ? Copy_String(mo.series, 0, -1) : mo.series;
14751475
}
14761476

14771477

src/core/t-string.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2023 Rebol Open Source Developers
6+
** Copyright 2012-2024 Rebol Open Source Developers
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -173,7 +173,7 @@ static REBSER *make_string(REBVAL *arg, REBOOL make)
173173
}
174174
// MAKE/TO <type> <any-word>
175175
else if (ANY_WORD(arg) || ANY_PATH(arg)) {
176-
ser = Copy_Form_Value(arg, TRUE);
176+
ser = Form_Value(arg, TRUE, TRUE);
177177
//ser = Append_UTF8(0, Get_Word_Name(arg), -1);
178178
}
179179
// MAKE/TO <type> #"A"
@@ -186,7 +186,7 @@ static REBSER *make_string(REBVAL *arg, REBOOL make)
186186
// ser = Make_Binary(0);
187187
// }
188188
else
189-
ser = Copy_Form_Value(arg, 1<<MOPT_TIGHT);
189+
ser = Form_Value(arg, 1<<MOPT_TIGHT, TRUE);
190190

191191
return ser;
192192
}
@@ -636,7 +636,7 @@ static struct {
636636
else {
637637
if (IS_CHAR(arg) || IS_BITSET(arg)) len = 1;
638638
else if (!ANY_STR(arg)) {
639-
Set_String(arg, Copy_Form_Value(arg, 0));
639+
Set_String(arg, Form_Value(arg, 0, FALSE));
640640
}
641641
}
642642

0 commit comments

Comments
 (0)