Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lsp/source/served/lsp/filereader.d
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,18 @@ abstract class FileReader : Thread

string yieldLine(bool* whileThisIs = null, bool equalToThis = true)
{
// hoisted: as a literal this allocates on every call, and this runs once
// per main loop iteration even when idle
static immutable ubyte[2] crlf = [cast(ubyte) '\r', cast(ubyte) '\n'];

ptrdiff_t index;
string ret;
while (whileThisIs is null || *whileThisIs == equalToThis)
{
bool hasData;
synchronized (mutex)
{
index = data.countUntil([cast(ubyte) '\r', cast(ubyte) '\n']);
index = data.countUntil(crlf[]);
if (index != -1)
{
ret = cast(string) data[0 .. index].dup;
Expand Down
Loading