Skip to content

Commit 0e8c8dd

Browse files
committed
Optimized some copy operations.
Added copy constructor for FileIncoming.
1 parent 4b3ee40 commit 0e8c8dd

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/server/protocol/ServerHttp2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,9 @@ namespace HttpServer
590590
}
591591
} else {
592592
std::copy(
593-
buf.cbegin() + length,
594-
buf.cbegin() + read_size,
595-
buf.begin()
593+
buf.data() + length,
594+
buf.data() + read_size,
595+
buf.data()
596596
);
597597

598598
read_size -= length;

src/server/protocol/ServerHttp2Protocol.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ namespace HttpServer
106106
}
107107
}
108108

109-
const size_t frame_size = data_size + padding_size;
109+
const uint32_t frame_size = static_cast<uint32_t>(
110+
data_size + padding_size
111+
);
110112

111113
buf.resize(frame_size + Http2::FRAME_HEADER_SIZE);
112114

@@ -141,15 +143,15 @@ namespace HttpServer
141143

142144
this->stream->setHttp2FrameHeader(
143145
buf.data(),
144-
static_cast<uint32_t>(frame_size),
146+
frame_size,
145147
Http2::FrameType::DATA,
146148
flags
147149
);
148150

149151
std::copy(
150152
data,
151153
data + data_size,
152-
buf.begin() + long(cur)
154+
buf.data() + cur
153155
);
154156

155157
if (padding) {

src/transfer/FileIncoming.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ namespace Transfer
1414
std::string file_type;
1515
size_t file_size;
1616

17-
private:
18-
FileIncoming() = delete;
19-
2017
public:
18+
FileIncoming() = default;
19+
2120
FileIncoming(
2221
std::string &&fileTmpName,
2322
std::string &&fileName,
@@ -30,6 +29,8 @@ namespace Transfer
3029

3130
~FileIncoming() noexcept = default;
3231

32+
FileIncoming &operator =(const FileIncoming &) = default;
33+
3334
const std::string &getTmpName() const noexcept;
3435
const std::string &getName() const noexcept;
3536
const std::string &getType() const noexcept;

0 commit comments

Comments
 (0)