Skip to content

Commit 811ac18

Browse files
committed
refactory HookRegistry
1 parent 998dbd2 commit 811ac18

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cucumber_cpp/library/HookRegistry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ namespace cucumber_cpp::library
128128
return registry.at(id);
129129
}
130130

131-
void HookRegistry::Register(std::string id, HookType type, std::optional<std::string_view> expression, std::optional<std::string_view> name, HookFactory factory, std::source_location sourceLocation)
131+
void HookRegistry::Register(const std::string& id, HookType type, std::optional<std::string_view> expression, std::optional<std::string_view> name, HookFactory factory, std::source_location sourceLocation)
132132
{
133-
registry.try_emplace(id, Definition{ id, type, expression, name, factory, sourceLocation });
133+
registry.try_emplace(id, id, type, expression, name, factory, sourceLocation);
134134
}
135135
}

cucumber_cpp/library/HookRegistry.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "cucumber_cpp/library/util/Broadcaster.hpp"
1313
#include <cstddef>
1414
#include <cstdint>
15+
#include <functional>
1516
#include <map>
1617
#include <memory>
1718
#include <optional>
@@ -112,10 +113,10 @@ namespace cucumber_cpp::library
112113
const Definition& GetDefinitionById(const std::string& id) const;
113114

114115
private:
115-
void Register(std::string id, HookType type, std::optional<std::string_view> expression, std::optional<std::string_view> name, HookFactory factory, std::source_location sourceLocation);
116+
void Register(const std::string& id, HookType type, std::optional<std::string_view> expression, std::optional<std::string_view> name, HookFactory factory, std::source_location sourceLocation);
116117

117118
cucumber::gherkin::id_generator_ptr idGenerator;
118-
std::map<std::string, Definition> registry;
119+
std::map<std::string, Definition, std::less<>> registry;
119120
};
120121
}
121122

0 commit comments

Comments
 (0)