perf. use static_cast

This commit is contained in:
lhhxxxxx
2022-06-06 18:41:08 +08:00
parent 23d6d63c90
commit e6ad9b242b
3 changed files with 16 additions and 16 deletions

View File

@@ -33,7 +33,7 @@ Assistant::Assistant(AsstApiCallback callback, void* callback_arg)
LogTraceFunction;
m_status = std::make_shared<RuntimeStatus>();
m_ctrler = std::make_shared<Controller>(task_callback, (void*)this);
m_ctrler = std::make_shared<Controller>(task_callback, static_cast<void*>(this));
m_working_thread = std::thread(&Assistant::working_proc, this);
m_msg_thread = std::thread(&Assistant::msg_proc, this);
@@ -85,31 +85,31 @@ asst::Assistant::TaskId asst::Assistant::append_task(const std::string& type, co
std::shared_ptr<PackageTask> ptr = nullptr;
if (type == FightTask::TaskType) {
ptr = std::make_shared<FightTask>(task_callback, (void*)this);
ptr = std::make_shared<FightTask>(task_callback, static_cast<void*>(this));
}
else if (type == StartUpTask::TaskType) {
ptr = std::make_shared<StartUpTask>(task_callback, (void*)this);
ptr = std::make_shared<StartUpTask>(task_callback, static_cast<void*>(this));
}
else if (type == AwardTask::TaskType) {
ptr = std::make_shared<AwardTask>(task_callback, (void*)this);
ptr = std::make_shared<AwardTask>(task_callback, static_cast<void*>(this));
}
else if (type == VisitTask::TaskType) {
ptr = std::make_shared<VisitTask>(task_callback, (void*)this);
ptr = std::make_shared<VisitTask>(task_callback, static_cast<void*>(this));
}
else if (type == MallTask::TaskType) {
ptr = std::make_shared<MallTask>(task_callback, (void*)this);
ptr = std::make_shared<MallTask>(task_callback, static_cast<void*>(this));
}
else if (type == InfrastTask::TaskType) {
ptr = std::make_shared<InfrastTask>(task_callback, (void*)this);
ptr = std::make_shared<InfrastTask>(task_callback, static_cast<void*>(this));
}
else if (type == RecruitTask::TaskType) {
ptr = std::make_shared<RecruitTask>(task_callback, (void*)this);
ptr = std::make_shared<RecruitTask>(task_callback, static_cast<void*>(this));
}
else if (type == RoguelikeTask::TaskType) {
ptr = std::make_shared<RoguelikeTask>(task_callback, (void*)this);
ptr = std::make_shared<RoguelikeTask>(task_callback, static_cast<void*>(this));
}
else if (type == CopilotTask::TaskType) {
ptr = std::make_shared<CopilotTask>(task_callback, (void*)this);
ptr = std::make_shared<CopilotTask>(task_callback, static_cast<void*>(this));
}
#ifdef ASST_DEBUG
else if (type == DebugTask::TaskType) {
@@ -293,7 +293,7 @@ void Assistant::msg_proc()
void Assistant::task_callback(AsstMsg msg, const json::value& detail, void* custom_arg)
{
Assistant* p_this = (Assistant*)custom_arg;
Assistant* p_this = static_cast<Assistant*>(custom_arg);
json::value more_detail = detail;
more_detail["uuid"] = p_this->m_uuid;

View File

@@ -781,7 +781,7 @@ int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int
extra_cmd = utils::string_replace_all(extra_cmd, "[y1]", std::to_string(p2.y));
int end_x = 0, end_y = 0;
if (p2.x != p1.x) {
double k = (double)(p2.y - p1.y) / (p2.x - p1.x);
double k = static_cast<double>(p2.y - p1.y) / (p2.x - p1.x);
double temp = extra_swipe_dist / std::sqrt(1 + k * k);
end_x = p2.x + static_cast<int>((p2.x > p1.x ? -1.0 : 1.0) * temp);
end_y = p2.y + static_cast<int>((p2.y > p1.y ? -1.0 : 1.0) * std::fabs(k) * temp);

View File

@@ -89,10 +89,10 @@ std::vector<asst::TextRect> asst::OcrPack::recognize(const cv::Mat image, const
int* box = m_boxes_buffer + i * 8;
int x_collect[4] = { *(box + 0), *(box + 2), *(box + 4), *(box + 6) };
int y_collect[4] = { *(box + 1), *(box + 3), *(box + 5), *(box + 7) };
int left = int(*std::min_element(x_collect, x_collect + 4));
int right = int(*std::max_element(x_collect, x_collect + 4));
int top = int(*std::min_element(y_collect, y_collect + 4));
int bottom = int(*std::max_element(y_collect, y_collect + 4));
int left = static_cast<int>(*std::min_element(x_collect, x_collect + 4));
int right = static_cast<int>(*std::max_element(x_collect, x_collect + 4));
int top = static_cast<int>(*std::min_element(y_collect, y_collect + 4));
int bottom = static_cast<int>(*std::max_element(y_collect, y_collect + 4));
rect = Rect(left, top, right - left, bottom - top);
}
std::string text(*(m_strs_buffer + i));