Skip to content

Commit

Permalink
Use static constexpr in class
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Feb 10, 2020
1 parent a0f97cd commit bb27d5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/submap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ void maptile_soa<sx, sy>::swap_soa_tile( const point &p, maptile_soa<1, 1> &othe

submap::submap()
{
constexpr size_t elements = SEEX * SEEY;

std::uninitialized_fill_n( &ter[0][0], elements, t_null );
std::uninitialized_fill_n( &frn[0][0], elements, f_null );
std::uninitialized_fill_n( &lum[0][0], elements, 0 );
Expand Down
11 changes: 5 additions & 6 deletions src/submap.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class submap : maptile_soa<SEEX, SEEY>
}

void set_all_traps( const trap_id &trap ) {
constexpr size_t block_size = SEEX * SEEY;
std::uninitialized_fill_n( &trp[0][0], block_size, trap );
std::uninitialized_fill_n( &trp[0][0], elements, trap );
}

furn_id get_furn( const point &p ) const {
Expand All @@ -88,8 +87,7 @@ class submap : maptile_soa<SEEX, SEEY>
}

void set_all_furn( const furn_id &furn ) {
constexpr size_t block_size = SEEX * SEEY;
std::uninitialized_fill_n( &frn[0][0], block_size, furn );
std::uninitialized_fill_n( &frn[0][0], elements, furn );
}

ter_id get_ter( const point &p ) const {
Expand All @@ -102,8 +100,7 @@ class submap : maptile_soa<SEEX, SEEY>
}

void set_all_ter( const ter_id &terr ) {
constexpr size_t block_size = SEEX * SEEY;
std::uninitialized_fill_n( &ter[0][0], block_size, terr );
std::uninitialized_fill_n( &ter[0][0], elements, terr );
}

int get_radiation( const point &p ) const {
Expand Down Expand Up @@ -251,6 +248,8 @@ class submap : maptile_soa<SEEX, SEEY>
int temperature = 0;

void update_legacy_computer();

static constexpr size_t elements = SEEX * SEEY;
};

/**
Expand Down

0 comments on commit bb27d5a

Please sign in to comment.