Skip to content

Commit 90389e6

Browse files
authored
use sink instead of OutBuffer (dlang#23013)
1 parent 7479af4 commit 90389e6

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

compiler/src/dmd/lexer.d

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ class Lexer
16431643
if (c == terminator)
16441644
{
16451645
if (supportInterpolation)
1646-
result.appendInterpolatedPart(stringbuffer);
1646+
result.appendInterpolatedPart(stringbuffer[]);
16471647
else
16481648
result.setString(stringbuffer[]);
16491649

@@ -1951,11 +1951,11 @@ class Lexer
19511951
case TOK.rightCurly:
19521952
if (--nest == 0)
19531953
{
1954+
const length = p - 1 - pstart;
19541955
if (supportInterpolation)
1955-
result.appendInterpolatedPart(pstart, p - 1 - pstart);
1956+
result.appendInterpolatedPart(pstart[0 .. length]);
19561957
else
1957-
result.setString(pstart[0 .. p - 1 - pstart]);
1958-
1958+
result.setString(pstart[0 .. length]);
19591959
stringPostfix(result);
19601960
return;
19611961
}
@@ -1994,7 +1994,7 @@ class Lexer
19941994
// expression, at this level we need to scan until the closing ')'
19951995

19961996
// always put the string part in first
1997-
token.appendInterpolatedPart(stringbuffer);
1997+
token.appendInterpolatedPart(stringbuffer[]);
19981998
stringbuffer.setsize(0);
19991999

20002000
int openParenCount = 1;
@@ -2119,7 +2119,7 @@ class Lexer
21192119
if (c != tc)
21202120
goto default;
21212121
if (supportInterpolation)
2122-
t.appendInterpolatedPart(stringbuffer);
2122+
t.appendInterpolatedPart(stringbuffer[]);
21232123
else
21242124
t.setString(stringbuffer[]);
21252125
if (!Ccompile)

compiler/src/dmd/tokens.d

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -925,27 +925,17 @@ nothrow:
925925
return 0;
926926
}
927927

928-
extern(D) void appendInterpolatedPart(const ref OutBuffer buf)
929-
{
930-
appendInterpolatedPart(cast(const(char)*)buf[].ptr, buf.length);
931-
}
932-
933928
extern(D) void appendInterpolatedPart(const(char)[] str)
934-
{
935-
appendInterpolatedPart(str.ptr, str.length);
936-
}
937-
938-
extern(D) void appendInterpolatedPart(const(char)* ptr, size_t length)
939929
{
940930
assert(value == TOK.interpolated);
941931
if (interpolatedSet is null)
942932
interpolatedSet = new InterpolatedSet;
943933

944-
auto s = cast(char*)mem.xmalloc_noscan(length + 1);
945-
memcpy(s, ptr, length);
946-
s[length] = 0;
934+
auto s = cast(char*)mem.xmalloc_noscan(str.length + 1);
935+
memcpy(s, str.ptr, str.length);
936+
s[str.length] = 0;
947937

948-
interpolatedSet.parts ~= cast(string) s[0 .. length];
938+
interpolatedSet.parts ~= cast(string) s[0 .. str.length];
949939
}
950940

951941
/****

0 commit comments

Comments
 (0)