Skip to content

Commit

Permalink
[native] Minor refactor in ConfigReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkdutta committed Mar 25, 2024
1 parent 4e2320c commit 71bb174
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions presto-native-execution/presto_cpp/main/common/ConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ std::unordered_map<std::string, std::string> readConfig(
std::string line;
while (getline(configFile, line)) {
line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end());
if (line[0] == '#' || line.empty()) {
if (line.empty() || line[0] == '#') {
continue;
}
auto delimiterPos = line.find('=');
auto name = line.substr(0, delimiterPos);
auto value = line.substr(delimiterPos + 1);
properties.emplace(name, value);

std::vector<std::string> configParts;
folly::split('=', line, configParts);
VELOX_USER_CHECK_EQ(configParts.size(), 2, "Malformed config: {}", line);
properties.emplace(configParts[0], configParts[1]);
}

return properties;
Expand Down

0 comments on commit 71bb174

Please sign in to comment.