Skip to content

Commit 64a9eaa

Browse files
log_manager: directly create metadata from journal
Eliminate one call to `additional_data::parse` by having the journal metadata search use a `map` for the metadata instead of a `vector`. Tested: Test cases pass. Signed-off-by: Patrick Williams <[email protected]> Change-Id: Ib1af2e2c96cb9b385fd0f22a63043973b7e2ae14
1 parent ea21d99 commit 64a9eaa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

log_manager.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ uint32_t Manager::commitWithLvl(uint64_t transactionId, std::string errMsg,
8585
void Manager::_commit(uint64_t transactionId [[maybe_unused]],
8686
std::string&& errMsg, Entry::Level errLvl)
8787
{
88-
std::vector<std::string> additionalData{};
88+
std::map<std::string, std::string> additionalData{};
8989

9090
// When running as a test-case, the system may have a LOT of journal
9191
// data and we may not have permissions to do some of the journal sync
@@ -172,7 +172,13 @@ void Manager::_commit(uint64_t transactionId [[maybe_unused]],
172172
}
173173

174174
// Metadata variable found, save it and remove it from the set.
175-
additionalData.emplace_back(data, length);
175+
std::string metadata(data, length);
176+
if (auto pos = metadata.find('='); pos != std::string::npos)
177+
{
178+
auto key = metadata.substr(0, pos);
179+
auto value = metadata.substr(pos + 1);
180+
additionalData.emplace(std::move(key), std::move(value));
181+
}
176182
i = metalist.erase(i);
177183
}
178184
if (metalist.empty())
@@ -193,7 +199,7 @@ void Manager::_commit(uint64_t transactionId [[maybe_unused]],
193199

194200
sd_journal_close(j);
195201
}
196-
createEntry(errMsg, errLvl, util::additional_data::parse(additionalData));
202+
createEntry(errMsg, errLvl, additionalData);
197203
}
198204

199205
auto Manager::createEntry(

0 commit comments

Comments
 (0)