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

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

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