From c2cff2cc7885429d917830dbe8425b7b05a1a618 Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Fri, 10 May 2024 11:03:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E5=81=9A=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B0=8F=E7=9A=84inline=EF=BC=8C=E5=A4=A7=E5=A4=B4=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=EF=BC=8C=E8=BF=98=E6=98=AF=E8=A6=81=E5=8A=A8=E8=BF=99?= =?UTF-8?q?=E4=B8=AAscheduler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nba/include/nba/common/punning.hpp | 2 +- src/nba/include/nba/scheduler.hpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/nba/include/nba/common/punning.hpp b/src/nba/include/nba/common/punning.hpp index b929514..ea48cae 100644 --- a/src/nba/include/nba/common/punning.hpp +++ b/src/nba/include/nba/common/punning.hpp @@ -13,7 +13,7 @@ namespace nba { template -T read(void const* data, uint offset) { +inline T read(void const* data, uint offset) { T value; std::memcpy(&value, (u8*)data + offset, sizeof(T)); return value; diff --git a/src/nba/include/nba/scheduler.hpp b/src/nba/include/nba/scheduler.hpp index c79db49..0323186 100644 --- a/src/nba/include/nba/scheduler.hpp +++ b/src/nba/include/nba/scheduler.hpp @@ -249,6 +249,14 @@ private: static constexpr int LeftChild(int n) { return n * 2 + 1; } static constexpr int RightChild(int n) { return n * 2 + 2; } + void ALWAYS_INLINE Swap(int i, int j) { + auto tmp = heap[i]; + heap[i] = heap[j]; + heap[j] = tmp; + heap[i]->handle = i; + heap[j]->handle = j; + } + void Step(u64 timestamp_next) { while(heap[0]->timestamp <= timestamp_next && heap_size > 0) { auto event = heap[0]; @@ -273,14 +281,6 @@ private: } } - void Swap(int i, int j) { - auto tmp = heap[i]; - heap[i] = heap[j]; - heap[j] = tmp; - heap[i]->handle = i; - heap[j]->handle = j; - } - void Heapify(int n) { int l = LeftChild(n); int r = RightChild(n);