Skip to content

Commit a112a07

Browse files
committed
Minor comments in HttpServer.ts.
1 parent 0eb249a commit a112a07

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/NodeJS/Javascript/Servers/OutOfProcess/Http/HttpServer.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ function demarcateMessageEndings(outputStream: NodeJS.WritableStream) {
278278
if (typeof value === 'string') {
279279
// Node appends a new line character at the end of the message. This facilitates reading of the stream: the process reading it reads messages line by line -
280280
// characters stay in its buffer until a new line character is received. This means that the null terminating character must appear before the last
281-
// new line character of the message. This approach is slightly heavy handed in that it removes all whitespace at the end of the message, generally,
282-
// such whitespace is pointless.
283-
arguments[0] = value.trimRight() + '\0\n';
281+
// new line character of the message. This approach is inefficent since it allocates 2 new strings.
282+
//
283+
// TODO consider sending '\0\n' as a demarcator after sending value (profile). Also need to check if logging from worker threads might affect
284+
// such an approach.
285+
arguments[0] = value.slice(0, value.length - 1) + '\0\n';
284286
}
285287

286288
origWriteFunction.apply(this, arguments);

0 commit comments

Comments
 (0)