summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-08-28 20:26:32 +0100
committerPaul Buetow <paul@buetow.org>2021-08-28 20:28:34 +0100
commit23982f331c2154a66b86d596226c24454fd06be5 (patch)
treef8aa72eb5110a4de914f28a063b528fd166a3a6b /internal/server
parent8c2e94030d0e31289c35fcfb56499707fd4a7ccd (diff)
1. Major performance gain by not checking for file truncation aftter
each bytes read. 2. Introduce field separator to the protocol package.
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/handlers/serverhandler.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/server/handlers/serverhandler.go b/internal/server/handlers/serverhandler.go
index f5aefa2..14fc5d0 100644
--- a/internal/server/handlers/serverhandler.go
+++ b/internal/server/handlers/serverhandler.go
@@ -120,15 +120,15 @@ func (h *ServerHandler) Read(p []byte) (n int, err error) {
case line := <-h.lines:
buf := pool.BytesBuffer.Get().(*bytes.Buffer)
buf.WriteString("REMOTE")
- buf.WriteByte(protocol.FieldDelimiter)
+ buf.WriteString(protocol.FieldDelimiter)
buf.WriteString(h.hostname)
- buf.WriteByte(protocol.FieldDelimiter)
+ buf.WriteString(protocol.FieldDelimiter)
buf.WriteString(fmt.Sprintf("%3d", line.TransmittedPerc))
- buf.WriteByte(protocol.FieldDelimiter)
+ buf.WriteString(protocol.FieldDelimiter)
buf.WriteString(fmt.Sprintf("%v", line.Count))
- buf.WriteByte(protocol.FieldDelimiter)
+ buf.WriteString(protocol.FieldDelimiter)
buf.WriteString(line.SourceID)
- buf.WriteByte(protocol.FieldDelimiter)
+ buf.WriteString(protocol.FieldDelimiter)
payload := append(buf.Bytes(), line.Content.Bytes()...)
n = copy(p, payload)
pool.RecycleBytesBuffer(buf)