diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-01-27 12:30:13 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2017-01-27 21:06:09 +0100 |
commit | 2f8f58512dbb478f23149b57d33f788c26c04445 (patch) | |
tree | a604c7511f0eb6a4369ae094366c809fea0b8f38 /apt-pkg | |
parent | 4c02370f5558e93afc554318f917468983df35f6 (diff) |
avoid malloc if option whitelist is disabled (default)
Config options are checked in various paths, so making "useless" memory
allocations wastes time and can also cause problems like #852757.
The unneeded malloc was added in ae73a2944a89e0d2406a2aab4a4c082e1e9da3f9.
(We have no explicit malloc here – its std:string doing this internally)
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/configuration.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 8005ef7d4..78a98d614 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -92,10 +92,9 @@ static ConfigType getConfigType(std::string const &type) /*{{{*/ return ConfigType::UNDEFINED; } /*}}}*/ -static void checkFindConfigOptionType(std::string name, ConfigType const type)/*{{{*/ +// checkFindConfigOptionType - workhorse of option checking /*{{{*/ +static void checkFindConfigOptionTypeInternal(std::string name, ConfigType const type) { - if (apt_known_config.empty()) - return; std::transform(name.begin(), name.end(), name.begin(), ::tolower); auto known = apt_known_config.find(name); if (known == apt_known_config.cend()) @@ -152,6 +151,12 @@ static void checkFindConfigOptionType(std::string name, ConfigType const type)/* name.c_str(), getConfigTypeString(known->second).c_str(), getConfigTypeString(type).c_str()); } } +static void checkFindConfigOptionType(char const * const name, ConfigType const type) +{ + if (apt_known_config.empty()) + return; + checkFindConfigOptionTypeInternal(name, type); +} /*}}}*/ static bool LoadConfigurationIndex(std::string const &filename) /*{{{*/ { |