diff --git a/tooling/backend/js_single_stepper.cpp b/tooling/backend/js_single_stepper.cpp index 3e5555b..a2257eb 100644 --- a/tooling/backend/js_single_stepper.cpp +++ b/tooling/backend/js_single_stepper.cpp @@ -107,7 +107,7 @@ std::list SingleStepper::GetStepRanges(DebugInfoExtractor *extrac } std::unique_ptr SingleStepper::GetStepper(const EcmaVM *ecmaVm, - SingleStepper::Type type) + SingleStepper::Type type) { std::unique_ptr ptMethod = DebuggerApi::GetMethod(ecmaVm); ASSERT(ptMethod != nullptr); diff --git a/tooling/client/ark_multi/main.cpp b/tooling/client/ark_multi/main.cpp index 8bc9983..87958d4 100644 --- a/tooling/client/ark_multi/main.cpp +++ b/tooling/client/ark_multi/main.cpp @@ -63,6 +63,16 @@ bool ExecutePandaFile(panda::ecmascript::EcmaVM *vm, return ret; } +std::pair GetNextPara() +{ + std::string fileName = *g_iter; + std::string fileAbc = fileName.substr(fileName.find_last_of('/') + 1); + std::string entry = fileAbc.substr(0, fileAbc.size() - 4); + g_iter++; + g_runningCount++; + return {fileName, entry}; +} + bool StartThread(uv_loop_t *loop) { uv_thread_t tid = 0; @@ -77,13 +87,8 @@ bool StartThread(uv_loop_t *loop) g_mutex.Unlock(); break; } - std::string fileName = *g_iter; - std::string fileAbc = fileName.substr(fileName.find_last_of('/') + 1); - std::string entry = fileAbc.substr(0, fileAbc.size() - 4); - g_iter++; - g_runningCount++; + auto [fileName, entry] = GetNextPara(); g_mutex.Unlock(); - panda::ecmascript::EcmaVM *vm = panda::JSNApi::CreateEcmaVM(g_runtimeOptions); if (vm == nullptr) { std::cerr << "Cannot create vm." << std::endl; @@ -92,7 +97,6 @@ bool StartThread(uv_loop_t *loop) panda::JSNApi::SetBundle(vm, !g_runtimeOptions.GetMergeAbc()); bool ret = ExecutePandaFile(vm, g_runtimeOptions, fileName, entry); panda::JSNApi::DestroyJSVM(vm); - auto loop = static_cast(arg); auto work = new uv_work_t; std::string msg; @@ -104,6 +108,8 @@ bool StartThread(uv_loop_t *loop) } work->data = new char[msg.size() + 1]; if (strncpy_s(static_cast(work->data), msg.size() + 1, msg.data(), msg.size()) != EOK) { + delete static_cast(work->data); + delete work; std::abort(); } uv_queue_work(loop, work, [] (uv_work_t*) {}, [] (uv_work_t* work, int) { @@ -194,8 +200,9 @@ int Main(const int argc, const char **argv) .count(); g_mutex.Lock(); + const long long timeUnit = 1000'000'000; std::cerr << "Run end, total file count: " << g_runningCount << ", used: " - << ((endTime - startTime) / 1000'000'000) << "s." << std::endl; + << ((endTime - startTime) / timeUnit) << "s." << std::endl; g_mutex.Unlock(); return 0; } diff --git a/tooling/dispatcher.cpp b/tooling/dispatcher.cpp index 94f5802..0a31933 100644 --- a/tooling/dispatcher.cpp +++ b/tooling/dispatcher.cpp @@ -65,8 +65,7 @@ DispatchRequest::DispatchRequest(const std::string &message) return; } std::string::size_type length = wholeMethod.length(); - std::string::size_type indexPoint; - indexPoint = wholeMethod.find_first_of('.', 0); + std::string::size_type indexPoint = wholeMethod.find_first_of('.', 0); if (indexPoint == std::string::npos || indexPoint == 0 || indexPoint == length - 1) { code_ = RequestCode::METHOD_FORMAT_ERROR; LOG_DEBUGGER(ERROR) << "method format error: " << wholeMethod; diff --git a/websocket/http.cpp b/websocket/http.cpp index 6295bcb..fb897a8 100644 --- a/websocket/http.cpp +++ b/websocket/http.cpp @@ -91,8 +91,8 @@ std::string HttpResponse::DecodeStatus(const std::string& response, std::string: auto statusStartPos = response.find_first_not_of(' ', versionEndPos); if (statusStartPos != std::string::npos) { auto statusEndPos = response.find(' ', statusStartPos); - if (statusEndPos != std::string::npos || - (statusEndPos = response.find(EOL, statusStartPos)) != std::string::npos) { + statusEndPos = (statusEndPos == std::string::npos) ? response.find(EOL, statusStartPos) : statusEndPos; + if (statusEndPos != std::string::npos) { return response.substr(statusStartPos, statusEndPos - statusStartPos); } }