Move string_map inside external_callbacks

It is not referenced outside this calls, thus the lifetime
can be safely handled by it.
This commit is contained in:
Patrick Niklaus 2015-04-10 12:40:30 +02:00
parent 34031aab1b
commit 5ff95dc32d
3 changed files with 7 additions and 12 deletions

View File

@ -101,13 +101,8 @@ int extractor::run(const ExtractorConfig &extractor_config)
// setup scripting environment
ScriptingEnvironment scripting_environment(extractor_config.profile_path.string().c_str());
// used to deduplicate street names: actually maps to name ids
std::unordered_map<std::string, NodeID> string_map;
string_map[""] = 0;
ExtractionContainers extraction_containers;
auto extractor_callbacks =
osrm::make_unique<ExtractorCallbacks>(extraction_containers, string_map);
auto extractor_callbacks = osrm::make_unique<ExtractorCallbacks>(extraction_containers);
const osmium::io::File input_file(extractor_config.input_path.string());
osmium::io::Reader reader(input_file);

View File

@ -41,10 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <vector>
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers,
std::unordered_map<std::string, NodeID> &string_map)
: string_map(string_map), external_memory(extraction_containers)
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers)
: external_memory(extraction_containers)
{
string_map[""] = 0;
}
/**

View File

@ -53,14 +53,14 @@ struct ExtractionNode;
class ExtractorCallbacks
{
private:
std::unordered_map<std::string, NodeID> &string_map;
// used to deduplicate street names: actually maps to name ids
std::unordered_map<std::string, NodeID> string_map;
ExtractionContainers &external_memory;
public:
ExtractorCallbacks() = delete;
ExtractorCallbacks(const ExtractorCallbacks &) = delete;
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers,
std::unordered_map<std::string, NodeID> &string_map);
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers);
// warning: caller needs to take care of synchronization!
void ProcessNode(const osmium::Node &current_node, const ExtractionNode &result_node);