diff --git a/src/klotski_core/common_code/common_code.h b/src/klotski_core/common_code/common_code.h index 03af9c1..68c048d 100644 --- a/src/klotski_core/common_code/common_code.h +++ b/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 diff --git a/src/klotski_core/raw_code/raw_code.h b/src/klotski_core/raw_code/raw_code.h index 7c28cd2..9b553ee 100644 --- a/src/klotski_core/raw_code/raw_code.h +++ b/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 diff --git a/src/klotski_core/short_code/short_code.h b/src/klotski_core/short_code/short_code.h index 0856d27..c72eb62 100644 --- a/src/klotski_core/short_code/short_code.h +++ b/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