Skip to content

Commit b9aafa8

Browse files
committed
fable: Check key existence with contains method, not at
This is more performant and doesn't use exceptions, which also improves debugging.
1 parent d27bbcb commit b9aafa8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fable/src/fable/conf.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ Conf::Conf(const std::string& file) : file_(file) {
4848

4949
bool Conf::has(const JsonPointer& key) const {
5050
try {
51-
data_.at(key);
52-
return true;
51+
return data_.contains(key);
5352
} catch (nlohmann::detail::exception&) {
5453
// Exception is probably one of json::out_of_range or json::parse_error.
5554
return false;

0 commit comments

Comments
 (0)