refactor(3p/nix/libutil): Replace string2Int & trim functions
Replaces these functions with corresponding functions from Abseil, namely absl::StripAsciiWhitespace and absl::SimpleAtoi. In the course of doing this some minor things I encountered along the way were also refactored. This also changes the signatures of the various custom readFile functions to use absl::string_view types.
This commit is contained in:
parent
b371821db5
commit
98299da0fd
19 changed files with 84 additions and 72 deletions
6
third_party/nix/src/libexpr/names.cc
vendored
6
third_party/nix/src/libexpr/names.cc
vendored
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include <absl/strings/numbers.h>
|
||||
|
||||
#include "util.hh"
|
||||
|
||||
namespace nix {
|
||||
|
|
@ -68,8 +70,8 @@ std::string nextComponent(std::string::const_iterator& p,
|
|||
static bool componentsLT(const std::string& c1, const std::string& c2) {
|
||||
int n1;
|
||||
int n2;
|
||||
bool c1Num = string2Int(c1, n1);
|
||||
bool c2Num = string2Int(c2, n2);
|
||||
bool c1Num = absl::SimpleAtoi(c1, &n1);
|
||||
bool c2Num = absl::SimpleAtoi(c2, &n2);
|
||||
|
||||
if (c1Num && c2Num) {
|
||||
return n1 < n2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue