Skip to content

Commit 748e62e

Browse files
committed
fix(style): Replace std::map by std::unordered map where possible
Signed-off-by: Steffen Vogel <steffen.vogel@opal-rt.com>
1 parent e6b015a commit 748e62e

File tree

22 files changed

+59
-52
lines changed

22 files changed

+59
-52
lines changed

common/include/villas/graph/directed.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#include <algorithm>
1111
#include <fstream>
1212
#include <list>
13-
#include <map>
1413
#include <memory>
1514
#include <sstream>
1615
#include <stdexcept>
1716
#include <string>
17+
#include <unordered_map>
1818

1919
#include <villas/graph/edge.hpp>
2020
#include <villas/graph/vertex.hpp>
@@ -245,8 +245,8 @@ class DirectedGraph {
245245
VertexIdentifier lastVertexId;
246246
EdgeIdentifier lastEdgeId;
247247

248-
std::map<VertexIdentifier, std::shared_ptr<VertexType>> vertices;
249-
std::map<EdgeIdentifier, std::shared_ptr<EdgeType>> edges;
248+
std::unordered_map<VertexIdentifier, std::shared_ptr<VertexType>> vertices;
249+
std::unordered_map<EdgeIdentifier, std::shared_ptr<EdgeType>> edges;
250250

251251
Logger logger;
252252
};

common/include/villas/memory.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ class HostDmaRam {
275275
static HostDmaRamAllocator &getAllocator(int num = 0);
276276

277277
private:
278-
static std::map<int, std::unique_ptr<HostDmaRamAllocator>> allocators;
278+
static std::unordered_map<int, std::unique_ptr<HostDmaRamAllocator>>
279+
allocators;
279280

280281
static std::string getUdmaBufName(int num);
281282

common/include/villas/memory_manager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#pragma once
99

1010
#include <cstdint>
11-
#include <map>
1211
#include <stdexcept>
1312
#include <string>
13+
#include <unordered_map>
1414

1515
#include <fmt/ostream.h>
1616
#include <unistd.h>
@@ -214,7 +214,7 @@ class MemoryManager {
214214
MemoryGraph memoryGraph;
215215

216216
// Cache mapping of names to address space ids for fast lookup
217-
std::map<std::string, AddressSpaceId> addrSpaceLookup;
217+
std::unordered_map<std::string, AddressSpaceId> addrSpaceLookup;
218218

219219
// Logger for universal access in this class
220220
Logger logger;

common/include/villas/popen.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#pragma once
99

1010
#include <istream>
11-
#include <map>
1211
#include <memory>
1312
#include <ostream>
1413
#include <string>
14+
#include <unordered_map>
1515
#include <vector>
1616

1717
#include <ext/stdio_filebuf.h>
@@ -24,7 +24,7 @@ class Popen {
2424

2525
public:
2626
using arg_list = std::vector<std::string>;
27-
using env_map = std::map<std::string, std::string>;
27+
using env_map = std::unordered_map<std::string, std::string>;
2828

2929
using char_type = char;
3030
using stdio_buf = __gnu_cxx::stdio_filebuf<char_type>;

common/lib/log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <algorithm>
99
#include <list>
10-
#include <map>
10+
#include <unordered_map>
1111

1212
#include <fnmatch.h>
1313
#include <spdlog/sinks/basic_file_sink.h>
@@ -19,7 +19,7 @@
1919

2020
using namespace villas;
2121

22-
static std::map<spdlog::level::level_enum, std::string> levelNames = {
22+
static std::unordered_map<spdlog::level::level_enum, std::string> levelNames = {
2323
{spdlog::level::trace, "trc"}, {spdlog::level::debug, "dbg"},
2424
{spdlog::level::info, "info"}, {spdlog::level::warn, "warn"},
2525
{spdlog::level::err, "err"}, {spdlog::level::critical, "crit"},

common/lib/memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ HostRam::HostRamAllocator::HostRamAllocator()
155155
};
156156
}
157157

158-
std::map<int, std::unique_ptr<HostDmaRam::HostDmaRamAllocator>>
158+
std::unordered_map<int, std::unique_ptr<HostDmaRam::HostDmaRamAllocator>>
159159
HostDmaRam::allocators;
160160

161161
HostDmaRam::HostDmaRamAllocator::HostDmaRamAllocator(int num)

fpga/include/villas/fpga/card.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class Card {
4949

5050
protected:
5151
// Keep a map of already mapped memory blocks
52-
std::map<MemoryManager::AddressSpaceId, std::shared_ptr<MemoryBlock>>
52+
std::unordered_map<MemoryManager::AddressSpaceId,
53+
std::shared_ptr<MemoryBlock>>
5354
memoryBlocksMapped;
5455

5556
Logger logger;

fpga/include/villas/fpga/core.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#pragma once
1212

1313
#include <list>
14-
#include <map>
1514
#include <memory>
15+
#include <unordered_map>
1616

1717
#include <fmt/ostream.h>
1818
#include <jansson.h>
@@ -194,16 +194,18 @@ class Core {
194194
IpIdentifier id;
195195

196196
// All interrupts of this IP with their associated interrupt controller
197-
std::map<std::string, IrqPort> irqs;
197+
std::unordered_map<std::string, IrqPort> irqs;
198198

199199
// Cached translations from the process address space to each memory block
200-
std::map<MemoryBlockName, MemoryTranslation> addressTranslations;
200+
std::unordered_map<MemoryBlockName, MemoryTranslation> addressTranslations;
201201

202202
// Lookup for IP's slave address spaces (= memory blocks)
203-
std::map<MemoryBlockName, MemoryManager::AddressSpaceId> slaveAddressSpaces;
203+
std::unordered_map<MemoryBlockName, MemoryManager::AddressSpaceId>
204+
slaveAddressSpaces;
204205

205206
// AXI bus master interfaces to access memory somewhere
206-
std::map<std::string, MemoryManager::AddressSpaceId> busMasterInterfaces;
207+
std::unordered_map<std::string, MemoryManager::AddressSpaceId>
208+
busMasterInterfaces;
207209

208210
size_t baseaddr = 0;
209211
};

fpga/include/villas/fpga/ips/pcie.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class AxiPciExpressBridge : public Core {
3838
uintptr_t translation;
3939
};
4040

41-
std::map<std::string, AxiBar> axiToPcieTranslations;
42-
std::map<std::string, PciBar> pcieToAxiTranslations;
41+
std::unordered_map<std::string, AxiBar> axiToPcieTranslations;
42+
std::unordered_map<std::string, PciBar> pcieToAxiTranslations;
4343
};
4444

4545
class XDmaBridge : public AxiPciExpressBridge {

fpga/include/villas/fpga/ips/switch.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#pragma once
1212

13-
#include <map>
13+
#include <unordered_map>
1414

1515
#include <xilinx/xaxis_switch.h>
1616

@@ -45,7 +45,7 @@ class AxiStreamSwitch : public Node {
4545
XAxis_Switch xSwitch;
4646
XAxis_Switch_Config xConfig;
4747

48-
std::map<std::string, std::string> portMapping;
48+
std::unordered_map<std::string, std::string> portMapping;
4949
};
5050

5151
class AxiStreamSwitchFactory : NodeFactory {

0 commit comments

Comments
 (0)