Prefer std::copy_n over std::copy where appropriate.

std::copy_n saves us from having to do the addition manually.
This commit is contained in:
Rose
2023-03-16 16:24:36 -04:00
parent 3e79583e4e
commit 8d06ca7f4e
6 changed files with 13 additions and 13 deletions

View File

@@ -760,7 +760,7 @@ std::vector<uint8_t> readToEOF(int fd) {
ssize_t readSize = 0;
while ((readSize = read(fd, readBuffer, BUFFER_SIZE)) > 0) {
retData.reserve(retData.size() + readSize);
std::copy(readBuffer, readBuffer + readSize, std::back_inserter(retData));
std::copy_n(readBuffer, readSize, std::back_inserter(retData));
}
return retData;
}