Skip to content

Commit 889fa0e

Browse files
committed
Optimize code
1 parent b6bef2b commit 889fa0e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

ext-src/swoole_http_client_coro.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static int http_parser_on_body(llhttp_t *parser, const char *at, size_t length)
535535
}
536536
http->download_file = fp;
537537
}
538-
if (http->download_file->write(SW_STRINGL(http->body)) != (ssize_t) http->body->length) {
538+
if (http->download_file->write(http->body) != (ssize_t) http->body->length) {
539539
return -1;
540540
}
541541
http->body->clear();

include/swoole_file.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ class AsyncFile {
171171
bool close();
172172

173173
ssize_t read(void *buf, size_t count) const;
174-
ssize_t write(void *buf, size_t count) const;
174+
ssize_t write(const void *buf, size_t count) const;
175+
ssize_t write(const String *buf) const {
176+
return write(SW_STRINGL(buf));
177+
}
175178

176179
bool sync() const;
177180
bool truncate(off_t length) const;

src/coroutine/file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ssize_t AsyncFile::read(void *buf, size_t count) const {
4747
return swoole_coroutine_read(fd, buf, count);
4848
}
4949

50-
ssize_t AsyncFile::write(void *buf, size_t count) const {
50+
ssize_t AsyncFile::write(const void *buf, size_t count) const {
5151
return swoole_coroutine_write(fd, buf, count);
5252
}
5353

0 commit comments

Comments
 (0)