Commit 6c151936 authored by Pavel Vainerman's avatar Pavel Vainerman

Небольшая оптимизация, где можно перевёл std::map --> std::unordered_map

parent e3c855c5
......@@ -100,7 +100,7 @@ class MBSlave
bool verbose;
#if 0
typedef std::map<ModbusRTU::mbErrCode, unsigned int> ExchangeErrorMap;
typedef std::unordered_map<ModbusRTU::mbErrCode, unsigned int> ExchangeErrorMap;
ExchangeErrorMap errmap; /*!< статистика обмена */
ModbusRTU::mbErrCode prev;
......@@ -110,7 +110,7 @@ class MBSlave
long askCount; /*!< количество принятых запросов */
typedef std::map<int, std::string> FileList;
typedef std::unordered_map<int, std::string> FileList;
FileList flist;
#endif
long replyVal;
......
......@@ -98,7 +98,7 @@ class MBTCPServer
bool verbose;
long replyVal;
#if 0
typedef std::map<ModbusRTU::mbErrCode, unsigned int> ExchangeErrorMap;
typedef std::unordered_map<ModbusRTU::mbErrCode, unsigned int> ExchangeErrorMap;
ExchangeErrorMap errmap; /*!< статистика обмена */
ModbusRTU::mbErrCode prev;
......@@ -108,7 +108,7 @@ class MBTCPServer
long askCount; /*!< количество принятых запросов */
typedef std::map<int, std::string> FileList;
typedef std::unordered_map<int, std::string> FileList;
FileList flist;
#endif
......
......@@ -24,7 +24,7 @@
#ifndef DBServer_MySQL_H_
#define DBServer_MySQL_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <queue>
#include "UniSetTypes.h"
#include "MySQLInterface.h"
......@@ -155,7 +155,7 @@ class DBServer_MySQL:
}
protected:
typedef std::map<int, std::string> DBTableMap;
typedef std::unordered_map<int, std::string> DBTableMap;
virtual void initDBServer() override;
virtual void initDB( std::shared_ptr<MySQLInterface>& db ) {};
......
#ifndef DBServer_PostgreSQL_H_
#define DBServer_PostgreSQL_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <queue>
#include "UniSetTypes.h"
#include "PostgreSQLInterface.h"
......@@ -31,7 +31,7 @@ class DBServer_PostgreSQL:
}
protected:
typedef std::map<int, std::string> DBTableMap;
typedef std::unordered_map<int, std::string> DBTableMap;
virtual void initDBServer() override;
virtual void initDB( std::shared_ptr<PostgreSQLInterface>& db ) {};
......
......@@ -24,7 +24,7 @@
#ifndef DBServer_SQLite_H_
#define DBServer_SQLite_H_
// --------------------------------------------------------------------------
#include <map>
#include <unordered_map>
#include <queue>
#include "UniSetTypes.h"
#include "SQLiteInterface.h"
......@@ -155,7 +155,7 @@ class DBServer_SQLite:
}
protected:
typedef std::map<int, std::string> DBTableMap;
typedef std::unordered_map<int, std::string> DBTableMap;
virtual void initDBServer() override;
virtual void initDB( std::shared_ptr<SQLiteInterface>& db ) {};
......
......@@ -210,7 +210,7 @@ class MBExchange:
friend std::ostream& operator<<( std::ostream& os, RTUDevice& d );
typedef std::map<ModbusRTU::ModbusAddr, std::shared_ptr<RTUDevice>> RTUDeviceMap;
typedef std::unordered_map<ModbusRTU::ModbusAddr, std::shared_ptr<RTUDevice>> RTUDeviceMap;
friend std::ostream& operator<<( std::ostream& os, RTUDeviceMap& d );
void printMap(RTUDeviceMap& d);
......
......@@ -4,6 +4,7 @@
// -----------------------------------------------------------------------------
#include <string>
#include <map>
#include <unordered_map>
#include <list>
#include <ostream>
#include <cstring>
......@@ -103,7 +104,7 @@ namespace MTR
// ---------------------------
// вспомогательные функции и типы данных
typedef std::list<ModbusRTU::ModbusData> DataList;
typedef std::map<ModbusRTU::ModbusData, DataList> DataMap;
typedef std::unordered_map<ModbusRTU::ModbusData, DataList> DataMap;
const int attempts = 3; //
static const ModbusRTU::ModbusData skip[] = {48, 49, 59}; // registers which should not write
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment