Merge remote-tracking branch 'bseiller/ea_improve_survey_performance_by_changing_inorgancs_to_vector_int' into develop

develop
lethosor 2021-06-04 00:21:34 -04:00
commit bce6432ea6
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
3 changed files with 13 additions and 9 deletions

@ -46,6 +46,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `blueprint`: add the ``--cursor`` option to set the starting coordinate for the generated blueprints. a game cursor is no longer necessary if this option is used.
- `quickfort`: the Dreamfort blueprint set can now be comfortably built in a 1x1 embark
- `tweak` hide-priority: changed so that priorities stay hidden (or visible) when exiting and re-entering the designations menu
- `embark-assistant`: slightly improved performance of surveying and improved code a little
## Lua
- ``gui.Painter``: fixed error when calling ``viewport()`` method

@ -91,9 +91,12 @@ namespace embark_assist {
int16_t river_elevation = 100;
int8_t adamantine_level; // -1 = none, 0 .. 3 = cavern 1 .. magma sea. Currently not used beyond present/absent.
int8_t magma_level; // -1 = none, 0 .. 3 = cavern 3 .. surface/volcano
std::vector<bool> metals;
std::vector<bool> economics;
std::vector<bool> minerals;
// using uint8_t instead of bool as vector<bool> gets optimized for a small memory footprint which leads to a significant overhead when iterating over all entries,
// also there seems to be no template specialization for std::fill in MSVS C++11 in regards to std::vector<bool> and std::memset does not work as expected (=> not at all that is)
// have a look here https://github.com/DFHack/dfhack/pull/1771#discussion_r579498636 for the related discussion and furter resources
std::vector<uint8_t> metals;
std::vector<uint8_t> economics;
std::vector<uint8_t> minerals;
};
typedef std::array<std::array<mid_level_tile, 16>, 16> mid_level_tiles;

@ -1,5 +1,6 @@
#include <math.h>
#include <vector>
#include <cstring>
#include "Core.h"
#include <Console.h>
@ -909,15 +910,14 @@ void inline copy_incursion_values(embark_assist::defs::mid_level_tile_incursion_
//=================================================================================
void reset_mlt_inorganics(embark_assist::defs::mid_level_tiles &mlts) {
const uint16_t size = mlts[0][0].metals.size();
for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) {
embark_assist::defs::mid_level_tile &mlt = mlts[i][k];
for (uint16_t l = 0; l < size; l++) {
mlt.metals[l] = false;
mlt.economics[l] = false;
mlt.minerals[l] = false;
}
// std::memset is much faster than std::fill and also faster than direct assignment - also std::fill might be compiled to std::memset but is not guaranteed to happen
// have a look here for why: https://travisdowns.github.io/blog/2020/01/20/zero.html
std::memset(&mlt.metals[0], false, mlt.metals.size() * sizeof(mlt.metals[0]));
std::memset(&mlt.economics[0], false, mlt.economics.size() * sizeof(mlt.economics[0]));
std::memset(&mlt.minerals[0], false, mlt.minerals.size() * sizeof(mlt.minerals[0]));
}
}
}