Browse Source

update: codec function inlining

master
Dnomd343 1 year ago
parent
commit
4ea1570d43
  1. 2
      src/klotski_core/all_cases/basic_ranges.cc
  2. 2
      src/klotski_core/all_cases/basic_ranges.h
  3. 10
      src/klotski_core/common_code/common_code.cc
  4. 12
      src/klotski_core/common_code/common_code.h
  5. 10
      src/klotski_core/raw_code/raw_code.cc
  6. 12
      src/klotski_core/raw_code/raw_code.h
  7. 10
      src/klotski_core/short_code/short_code.cc
  8. 12
      src/klotski_core/short_code/short_code.h

2
src/klotski_core/all_cases/basic_ranges.cc

@ -70,7 +70,7 @@ void BasicRanges::generate(basic_ranges_t &release, generate_t info) {
constexpr auto MASK_10 = (uint32_t)0b10 << 30;
constexpr auto MASK_11 = (uint32_t)0b11 << 30;
/// nx: n4 n3 n2 n1
/// nx: n4 n3 n2 n1
/// 00000000 00000000 00000000 00000000 (32-bit)
struct build_t {
uint32_t nx; // (n4, n3, n2, n1)

2
src/klotski_core/all_cases/basic_ranges.h

@ -38,7 +38,7 @@ const uint32_t BASIC_RANGES_SIZE = 7311921;
class BasicRanges {
public:
/// Three basic states, one-way transition.
/// {NO_INIT} -> {BUILDING} -> {AVAILABLE}
/// {NOT_INIT} -> {BUILDING} -> {AVAILABLE}
enum Status {
NOT_INIT,
BUILDING,

10
src/klotski_core/common_code/common_code.cc

@ -5,16 +5,6 @@ namespace klotski {
using Common::range_reverse;
CommonCode CommonCode::create(uint64_t common_code) {
return CommonCode(common_code); // create from uint64_t
}
CommonCode CommonCode::unsafe_create(uint64_t common_code) noexcept { // create without check
auto tmp = CommonCode(); // init directly
tmp.code_ = common_code;
return tmp;
}
CommonCode::CommonCode(uint64_t common_code) {
if (!CommonCode::check(common_code)) { // check input common code
throw klotski::CommonCodeExp("common code invalid");

12
src/klotski_core/common_code/common_code.h

@ -130,6 +130,18 @@ public:
static CommonCodes convert(const ShortCodes &short_codes) noexcept;
};
/// CommonCode create
inline CommonCode CommonCode::create(uint64_t common_code) {
return CommonCode(common_code); // create from uint64_t
}
/// CommonCode create without check
inline CommonCode CommonCode::unsafe_create(uint64_t common_code) noexcept {
auto tmp = CommonCode(); // init directly
tmp.code_ = common_code;
return tmp;
}
/// Compare implements
inline bool operator==(uint64_t c1, const CommonCode &c2) noexcept { return c1 == c2.unwrap(); }
inline bool operator==(const CommonCode &c1, uint64_t c2) noexcept { return c1.unwrap() == c2; }

10
src/klotski_core/raw_code/raw_code.cc

@ -3,16 +3,6 @@
namespace klotski {
RawCode RawCode::create(uint64_t raw_code) {
return RawCode(raw_code);
}
RawCode RawCode::unsafe_create(uint64_t raw_code) noexcept { // create without check
auto tmp = RawCode(); // init directly
tmp.code_ = raw_code;
return tmp;
}
RawCode::RawCode(uint64_t raw_code) {
if (!RawCode::check(raw_code)) { // check input raw code
throw klotski::RawCodeExp("raw code invalid");

12
src/klotski_core/raw_code/raw_code.h

@ -116,6 +116,18 @@ public:
bool is_horizontal_mirror(const RawCode &raw_code) const noexcept;
};
/// RawCode create
inline RawCode RawCode::create(uint64_t raw_code) {
return RawCode(raw_code);
}
/// RawCode create without check
inline RawCode RawCode::unsafe_create(uint64_t raw_code) noexcept {
auto tmp = RawCode(); // init directly
tmp.code_ = raw_code;
return tmp;
}
/// Compare implements
inline bool operator==(uint64_t r1, const RawCode &r2) noexcept { return r1 == r2.unwrap(); }
inline bool operator==(const RawCode &r1, uint64_t r2) noexcept { return r1.unwrap() == r2; }

10
src/klotski_core/short_code/short_code.cc

@ -6,16 +6,6 @@ namespace klotski {
bool ShortCode::fast_mode_available_ = false;
bool ShortCode::normal_mode_available_ = false;
ShortCode ShortCode::create(uint32_t short_code) {
return ShortCode(short_code);
}
ShortCode ShortCode::unsafe_create(uint32_t short_code) noexcept { // create without check
auto tmp = ShortCode(); // init directly
tmp.code_ = short_code;
return tmp;
}
ShortCode::ShortCode(uint32_t short_code) {
if (!ShortCode::check(short_code)) { // check input short code
throw klotski::ShortCodeExp("short code invalid");

12
src/klotski_core/short_code/short_code.h

@ -141,6 +141,18 @@ public:
static ShortCodes convert(const CommonCodes &common_codes) noexcept;
};
/// ShortCode create
inline ShortCode ShortCode::create(uint32_t short_code) {
return ShortCode(short_code);
}
/// ShortCode create without check
inline ShortCode ShortCode::unsafe_create(uint32_t short_code) noexcept {
auto tmp = ShortCode(); // init directly
tmp.code_ = short_code;
return tmp;
}
/// Compare implements
inline bool operator==(uint32_t s1, const ShortCode &s2) noexcept { return s1 == s2.unwrap(); }
inline bool operator==(const ShortCode &s1, uint32_t s2) noexcept { return s1.unwrap() == s2; }

Loading…
Cancel
Save