Skip to content

Commit b873969

Browse files
committed
Re-add prependBytes, prepend, bracket
1 parent bd158a3 commit b873969

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/dmd/backend/outbuf.d

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,40 @@ struct Outbuffer
261261
writeString(cast(const(char)[])(s));
262262
}
263263

264+
/**
265+
* Inserts string at beginning of buffer.
266+
*/
267+
@trusted
268+
void prependBytes(const(char)* s)
269+
{
270+
prepend(s, strlen(s));
271+
}
272+
273+
/**
274+
* Inserts bytes at beginning of buffer.
275+
*/
276+
@trusted
277+
void prepend(const(void)* b, size_t len)
278+
{
279+
reserve(len);
280+
memmove(buf + len,buf,p - buf);
281+
memcpy(buf,b,len);
282+
p += len;
283+
}
284+
285+
/**
286+
* Bracket buffer contents with c1 and c2.
287+
*/
288+
@trusted
289+
void bracket(char c1,char c2)
290+
{
291+
reserve(2);
292+
memmove(buf + 1,buf,p - buf);
293+
buf[0] = c1;
294+
p[1] = c2;
295+
p += 2;
296+
}
297+
264298
/**
265299
* Returns the number of bytes written.
266300
*/

0 commit comments

Comments
 (0)