diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-05 04:05:20 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-05 04:05:20 +0100 |
commit | 21d183e1e6ddc93960a7f7f049e74d3b51186ddc (patch) | |
tree | 38f2ebba41950b1604f5a369316d6d0d5a925494 /src/core/hle | |
parent | Merge pull request #249 from lioncash/enum (diff) | |
parent | kernel: Shorten GetCount (diff) | |
download | yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar.gz yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar.bz2 yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar.lz yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar.xz yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.tar.zst yuzu-21d183e1e6ddc93960a7f7f049e74d3b51186ddc.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 13 | ||||
-rw-r--r-- | src/core/hle/kernel/kernel.h | 4 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 018000abd..80a34c2d5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include <algorithm> + #include "common/common.h" #include "core/core.h" @@ -37,7 +39,7 @@ Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) { return 0; } -bool ObjectPool::IsValid(Handle handle) { +bool ObjectPool::IsValid(Handle handle) const { int index = handle - HANDLE_OFFSET; if (index < 0) return false; @@ -75,13 +77,8 @@ void ObjectPool::List() { } } -int ObjectPool::GetCount() { - int count = 0; - for (int i = 0; i < MAX_COUNT; i++) { - if (occupied[i]) - count++; - } - return count; +int ObjectPool::GetCount() const { + return std::count(occupied.begin(), occupied.end(), true); } Object* ObjectPool::CreateByIDType(int type) { diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 8d3937ce8..00a2228bf 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -86,7 +86,7 @@ public: } } - bool IsValid(Handle handle); + bool IsValid(Handle handle) const; template <class T> T* Get(Handle handle) { @@ -142,7 +142,7 @@ public: Object* &operator [](Handle handle); void List(); void Clear(); - int GetCount(); + int GetCount() const; private: |