使用static_pointer_cast优化性能

This commit is contained in:
xia-chu
2023-04-28 22:04:38 +08:00
parent cdf97e7605
commit d2349f01bd
23 changed files with 59 additions and 57 deletions

View File

@@ -27,7 +27,7 @@ void HttpRequester::onResponseBody(const char *buf, size_t size) {
void HttpRequester::onResponseCompleted(const SockException &ex) {
if (ex && _retry++ < _max_retry) {
std::weak_ptr<HttpRequester> weak_self = std::dynamic_pointer_cast<HttpRequester>(shared_from_this());
std::weak_ptr<HttpRequester> weak_self = std::static_pointer_cast<HttpRequester>(shared_from_this());
getPoller()->doDelayTask(_retry_delay, [weak_self](){
if (auto self = weak_self.lock()) {
InfoL << "resend request " << self->getUrl() << " with retry " << self->getRetry();