Skip to content

Commit 757f288

Browse files
committed
[#3398] Moved to unordered set
1 parent 8ea3244 commit 757f288

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/lib/cc/default_credentials.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
namespace isc {
1111
namespace data {
1212

13-
const std::list<std::string> DefaultCredentials::DEFAULT_CREDENTIALS = {
13+
const std::unordered_set<std::string>
14+
DefaultCredentials::DEFAULT_CREDENTIALS = {
1415
#ifndef IGNORE_KEA_DEFAULT_CREDENTIALS
1516
#ifndef ALLOW_KEATEST
1617
"keatest",
@@ -22,12 +23,11 @@ const std::list<std::string> DefaultCredentials::DEFAULT_CREDENTIALS = {
2223
#endif
2324
};
2425

25-
void DefaultCredentials::check(const std::string& value) {
26-
for (auto const& cred : DEFAULT_CREDENTIALS) {
27-
if (value == cred) {
28-
isc_throw(DefaultCredential,
29-
"illegal use of a default value as credential");
30-
}
26+
void
27+
DefaultCredentials::check(const std::string& value) {
28+
if (DEFAULT_CREDENTIALS.count(value)) {
29+
isc_throw(DefaultCredential,
30+
"illegal use of a default value as credential");
3131
}
3232
}
3333

src/lib/cc/default_credentials.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define DEFAULT_CREDENTIALS_H
99

1010
#include <exceptions/exceptions.h>
11-
#include <list>
11+
#include <unordered_set>
1212
#include <string>
1313

1414
namespace isc {
@@ -24,9 +24,7 @@ class DefaultCredential : public Exception {
2424
/// @brief Base class for default credentials.
2525
struct DefaultCredentials {
2626
/// @brief Default credentials.
27-
///
28-
/// @note Using a list as there are only a few default credentials.
29-
static const std::list<std::string> DEFAULT_CREDENTIALS;
27+
static const std::unordered_set<std::string> DEFAULT_CREDENTIALS;
3028

3129
/// @brief Check if the value is a default credential.
3230
///

0 commit comments

Comments
 (0)