Browse Source

perf: codec unsafe create

master
Dnomd343 1 year ago
parent
commit
defdf7f952
  1. 6
      src/klotski_core/common_code/common_code.h
  2. 6
      src/klotski_core/raw_code/raw_code.h
  3. 6
      src/klotski_core/short_code/short_code.h

6
src/klotski_core/common_code/common_code.h

@ -132,14 +132,12 @@ public:
/// CommonCode create
inline CommonCode CommonCode::create(uint64_t common_code) {
return CommonCode(common_code); // create from uint64_t
return CommonCode(common_code); // with check
}
/// 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;
return *(CommonCode*)&common_code; // init directly
}
/// Compare implements

6
src/klotski_core/raw_code/raw_code.h

@ -118,14 +118,12 @@ public:
/// RawCode create
inline RawCode RawCode::create(uint64_t raw_code) {
return RawCode(raw_code);
return RawCode(raw_code); // with check
}
/// 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;
return *(RawCode*)&raw_code; // init directly
}
/// Compare implements

6
src/klotski_core/short_code/short_code.h

@ -143,14 +143,12 @@ public:
/// ShortCode create
inline ShortCode ShortCode::create(uint32_t short_code) {
return ShortCode(short_code);
return ShortCode(short_code); // with check
}
/// 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;
return *(ShortCode*)&short_code; // init directly
}
/// Compare implements

Loading…
Cancel
Save