mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
refactor(zebin decoder): parsing enums
This commit simplifies parsing of enums in zebin decoder and removes unnecessary tests. Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7b86c8da2e
commit
9bd2c7da2b
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
template <typename KeyT, typename ValueT, size_t NumElements>
|
||||
@@ -17,13 +18,23 @@ struct LookupArray {
|
||||
using LookupMapArrayT = std::array<std::pair<KeyT, ValueT>, NumElements>;
|
||||
constexpr LookupArray(const LookupMapArrayT &lookupArray) : lookupArray(lookupArray){};
|
||||
|
||||
constexpr ValueT lookUp(const KeyT &keyToFind) const {
|
||||
constexpr std::optional<ValueT> find(const KeyT &keyToFind) const {
|
||||
for (auto &[key, value] : lookupArray) {
|
||||
if (keyToFind == key) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
UNRECOVERABLE_IF(true);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
constexpr ValueT lookUp(const KeyT &keyToFind) const {
|
||||
auto value = find(keyToFind);
|
||||
UNRECOVERABLE_IF(false == value.has_value());
|
||||
return *value;
|
||||
}
|
||||
|
||||
constexpr size_t size() const {
|
||||
return NumElements;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user