Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8246ac8575e6
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ddfe4b562e99
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 12, 2020

  1. Avoid exit destructors.

    pleroy committed Mar 12, 2020
    Copy the full SHA
    140beb2 View commit details
  2. Merge pull request #2491 from pleroy/Linux

    Avoid exit destructors
    pleroy authored Mar 12, 2020
    Copy the full SHA
    ddfe4b5 View commit details
Showing with 10 additions and 7 deletions.
  1. +9 −6 base/flags.cpp
  2. +1 −1 base/flags.hpp
15 changes: 9 additions & 6 deletions base/flags.cpp
Original file line number Diff line number Diff line change
@@ -8,20 +8,20 @@ namespace principia {
namespace base {

void Flags::Clear() {
flags_.clear();
flags().clear();
}

void Flags::Set(std::string_view const name, std::string_view const value) {
flags_.emplace(std::string(name), std::string(value));
flags().emplace(std::string(name), std::string(value));
}

bool Flags::IsPresent(std::string_view const name) {
return flags_.find(std::string(name)) != flags_.end();
return flags().find(std::string(name)) != flags().end();
}

bool Flags::IsPresent(std::string_view const name,
std::string_view const value) {
auto const pair = flags_.equal_range(std::string(name));
auto const pair = flags().equal_range(std::string(name));
std::set<std::string> values;
for (auto it = pair.first; it != pair.second; ++it) {
if (it->second == value) {
@@ -32,15 +32,18 @@ bool Flags::IsPresent(std::string_view const name,
}

std::set<std::string> Flags::Values(std::string_view const name) {
auto const pair = flags_.equal_range(std::string(name));
auto const pair = flags().equal_range(std::string(name));
std::set<std::string> values;
for (auto it = pair.first; it != pair.second; ++it) {
values.insert(it->second);
}
return values;
}

std::multimap<std::string, std::string> Flags::flags_;
std::multimap<std::string, std::string>& Flags::flags() {
static auto* const flags = new std::multimap<std::string, std::string>();
return *flags;
}

} // namespace base
} // namespace principia
2 changes: 1 addition & 1 deletion base/flags.hpp
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ class Flags {
static std::set<std::string> Values(std::string_view name);

private:
static std::multimap<std::string, std::string> flags_;
static std::multimap<std::string, std::string>& flags();
};

} // namespace base