Move words_bigendian into if constexpr
`words_bigendian` is `constexpr`, so move the tests on it behind `if constexpr` to encourage the compiler to prune unreachable paths.
This commit is contained in:
parent
b948da1a1f
commit
316a4740a6
|
@ -968,7 +968,7 @@ static std::unique_ptr<grs_font> gr_internal_init_font(const char *fontname)
|
|||
const unsigned ft_h = font->ft_h;
|
||||
std::generate_n(ft_chars, nchars, [is_color, ft_h, &w, &ptr]{
|
||||
const unsigned s = INTEL_SHORT(*w);
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
*w = static_cast<uint16_t>(s);
|
||||
++w;
|
||||
const auto r = ptr;
|
||||
|
|
|
@ -1015,7 +1015,7 @@ void create_shortpos_little(const d_level_shared_segment_state &LevelSharedSegme
|
|||
create_shortpos_native(LevelSharedSegmentState, spp, objp);
|
||||
// swap the short values for the big-endian machines.
|
||||
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
spp.xo = INTEL_SHORT(spp.xo);
|
||||
spp.yo = INTEL_SHORT(spp.yo);
|
||||
|
|
|
@ -2200,7 +2200,7 @@ static void multi_do_controlcen_fire(const ubyte *buf)
|
|||
int count = 1;
|
||||
|
||||
memcpy(&to_target, buf+count, 12); count += 12;
|
||||
if (words_bigendian)// swap the vector to_target
|
||||
if constexpr (words_bigendian)// swap the vector to_target
|
||||
{
|
||||
to_target.x = INTEL_INT(to_target.x);
|
||||
to_target.y = INTEL_INT(to_target.y);
|
||||
|
@ -2235,7 +2235,7 @@ static void multi_do_create_powerup(fvmobjptr &vmobjptr, fvmsegptridx &vmsegptri
|
|||
count += 2;
|
||||
objnum_t objnum = GET_INTEL_SHORT(buf + count); count += 2;
|
||||
memcpy(&new_pos, buf+count, sizeof(vms_vector)); count+=sizeof(vms_vector);
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
new_pos.x = SWAPINT(new_pos.x);
|
||||
new_pos.y = SWAPINT(new_pos.y);
|
||||
|
@ -2970,7 +2970,7 @@ void multi_send_controlcen_fire(const vms_vector &to_goal, int best_gun_num, obj
|
|||
|
||||
count += 1;
|
||||
multi_command<MULTI_CONTROLCEN_FIRE> multibuf;
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
vms_vector swapped_vec;
|
||||
swapped_vec.x = INTEL_INT(static_cast<int>(to_goal.x));
|
||||
|
@ -3010,7 +3010,7 @@ void multi_send_create_powerup(const powerup_type_t powerup_type, const vcsegidx
|
|||
multibuf[count] = powerup_type; count += 1;
|
||||
PUT_INTEL_SHORT(&multibuf[count], segnum ); count += 2;
|
||||
PUT_INTEL_SHORT(&multibuf[count], objnum ); count += 2;
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
vms_vector swapped_vec;
|
||||
swapped_vec.x = INTEL_INT(static_cast<int>(pos.x));
|
||||
|
|
|
@ -526,7 +526,7 @@ void multi_send_robot_fire(const vmobjptridx_t obj, int gun_num, const vms_vecto
|
|||
PUT_INTEL_SHORT(&multibuf[loc], s);
|
||||
loc += 3;
|
||||
multibuf[loc] = gun_num; loc += 1;
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
vms_vector swapped_vec;
|
||||
swapped_vec.x = INTEL_INT(static_cast<int>(fire.x));
|
||||
|
@ -706,7 +706,7 @@ static void multi_send_create_robot_powerups(const object_base &del_obj)
|
|||
multibuf[loc] = del_obj.contains_type; loc += 1;
|
||||
multibuf[loc] = del_obj.contains_id; loc += 1;
|
||||
PUT_INTEL_SHORT(&multibuf[loc], del_obj.segnum); loc += 2;
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
{
|
||||
vms_vector swapped_vec;
|
||||
swapped_vec.x = INTEL_INT(static_cast<int>(del_obj.pos.x));
|
||||
|
|
|
@ -2027,7 +2027,7 @@ void net_udp_send_objects(void)
|
|||
PUT_INTEL_INT(&object_buffer[loc], remote_objnum); loc += 4;
|
||||
// use object_rw to send objects for now. if object sometime contains some day contains something useful the client should know about, we should use it. but by now it's also easier to use object_rw because then we also do not need fix64 timer values.
|
||||
multi_object_to_object_rw(vmobjptr(i), reinterpret_cast<object_rw *>(&object_buffer[loc]));
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
object_rw_swap(reinterpret_cast<object_rw *>(&object_buffer[loc]), 1);
|
||||
loc += sizeof(object_rw);
|
||||
}
|
||||
|
@ -2175,7 +2175,7 @@ static void net_udp_read_object_packet( ubyte *data )
|
|||
Assert(obj->segnum == segment_none);
|
||||
}
|
||||
Assert(objnum < MAX_OBJECTS);
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
object_rw_swap(reinterpret_cast<object_rw *>(&data[loc]), 1);
|
||||
multi_object_rw_to_object(reinterpret_cast<object_rw *>(&data[loc]), obj);
|
||||
loc += sizeof(object_rw);
|
||||
|
|
|
@ -417,7 +417,7 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info
|
|||
#if DXX_WORDS_NEED_ALIGNMENT
|
||||
align_polygon_model_data(pm);
|
||||
#endif
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
swap_polygon_model_data(pm->model_data.get());
|
||||
return pm;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ void polygon_model_data_read(polymodel *pm, PHYSFS_File *fp)
|
|||
#if DXX_WORDS_NEED_ALIGNMENT
|
||||
align_polygon_model_data(pm);
|
||||
#endif
|
||||
if (words_bigendian)
|
||||
if constexpr (words_bigendian)
|
||||
swap_polygon_model_data(pm->model_data.get());
|
||||
#if defined(DXX_BUILD_DESCENT_I)
|
||||
g3_validate_polygon_model(pm->model_data.get(), model_data_size);
|
||||
|
|
Loading…
Reference in a new issue