diff options
author | jade <lix@jade.fyi> | 2024-05-30 14:57:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@lix-systems> | 2024-05-30 14:57:37 +0000 |
commit | 18aa3e1d570b4ecbb9962376e5fba5757dad8da9 (patch) | |
tree | ad9edb3d85c7f3e9b6a33f65efeebbdbc9bd243b /src/libutil/strings.hh | |
parent | 53d40888ffe8238ab5baf6a9d1a7481c29e9c65d (diff) | |
parent | 7575db522e9008685c4009423398f6900a16bcce (diff) |
Merge "Remove 100s of CPU time (10%) from build times (1465s -> 1302s)" into main
Diffstat (limited to 'src/libutil/strings.hh')
-rw-r--r-- | src/libutil/strings.hh | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/libutil/strings.hh b/src/libutil/strings.hh index daeb5be50..03dff8160 100644 --- a/src/libutil/strings.hh +++ b/src/libutil/strings.hh @@ -4,7 +4,6 @@ #include "error.hh" #include "types.hh" -#include <boost/lexical_cast.hpp> #include <vector> namespace nix { @@ -130,16 +129,7 @@ inline std::string rewriteStrings(std::string s, const StringMap & rewrites) * Parse a string into an integer. */ template<class N> -std::optional<N> string2Int(const std::string_view s) -{ - if (s.substr(0, 1) == "-" && !std::numeric_limits<N>::is_signed) - return std::nullopt; - try { - return boost::lexical_cast<N>(s.data(), s.size()); - } catch (const boost::bad_lexical_cast &) { - return std::nullopt; - } -} +std::optional<N> string2Int(const std::string_view s); /** * Like string2Int(), but support an optional suffix 'K', 'M', 'G' or @@ -169,14 +159,7 @@ N string2IntWithUnitPrefix(std::string_view s) * Parse a string into a float. */ template<class N> -std::optional<N> string2Float(const std::string_view s) -{ - try { - return boost::lexical_cast<N>(s.data(), s.size()); - } catch (const boost::bad_lexical_cast &) { - return std::nullopt; - } -} +std::optional<N> string2Float(const std::string_view s); /** |