From 111d695ac0c2f5c1a1248aa489cedac242a1f71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 28 Jul 2014 19:04:13 +0200 Subject: [PATCH] gopher: Use a BStackOrHeapArray as temporary buffer And move it out of the loop, no need to construct it at each iteration anyway. --- src/kits/network/libnetapi/GopherRequest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kits/network/libnetapi/GopherRequest.cpp b/src/kits/network/libnetapi/GopherRequest.cpp index b9c1392f08..9af982068f 100644 --- a/src/kits/network/libnetapi/GopherRequest.cpp +++ b/src/kits/network/libnetapi/GopherRequest.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -266,11 +267,11 @@ BGopherRequest::_ProtocolLoop() //ssize_t bytesReceived = 0; //ssize_t bytesTotal = 0; bool dataValidated = false; + BStackOrHeapArray chunk(kGopherBufferSize); while (!fQuit && !receiveEnd) { fSocket->WaitForReadable(); - BNetBuffer chunk(kGopherBufferSize); - bytesRead = fSocket->Read(chunk.Data(), kGopherBufferSize); + bytesRead = fSocket->Read(chunk, kGopherBufferSize); if (bytesRead < 0) { readError = bytesRead; @@ -278,7 +279,7 @@ BGopherRequest::_ProtocolLoop() } else if (bytesRead == 0) receiveEnd = true; - fInputBuffer.AppendData(chunk.Data(), bytesRead); + fInputBuffer.AppendData(chunk, bytesRead); if (!dataValidated) { size_t i;