refactor(3p/nix/libutil): Replace hasPrefix/Suffix with Abseil

Uses the equivalent absl::StartsWith and absl::EndsWith functions
instead.
This commit is contained in:
Vincent Ambo 2020-05-25 02:19:01 +01:00
parent 8cf1322a6f
commit b99b368d17
21 changed files with 69 additions and 57 deletions

View file

@ -1,5 +1,6 @@
#include <algorithm>
#include <absl/strings/match.h>
#include <fcntl.h>
#include <glog/logging.h>
#include <sys/stat.h>
@ -56,10 +57,10 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) {
* Python package brings its own
* `$out/lib/pythonX.Y/site-packages/easy-install.pth'.)
*/
if (hasSuffix(srcFile, "/propagated-build-inputs") ||
hasSuffix(srcFile, "/nix-support") ||
hasSuffix(srcFile, "/perllocal.pod") ||
hasSuffix(srcFile, "/info/dir") || hasSuffix(srcFile, "/log"))
if (absl::EndsWith(srcFile, "/propagated-build-inputs") ||
absl::EndsWith(srcFile, "/nix-support") ||
absl::EndsWith(srcFile, "/perllocal.pod") ||
absl::EndsWith(srcFile, "/info/dir") || absl::EndsWith(srcFile, "/log"))
continue;
else if (S_ISDIR(srcSt.st_mode)) {

View file

@ -1,3 +1,4 @@
#include <absl/strings/match.h>
#include <glog/logging.h>
#include "archive.hh"
@ -41,7 +42,7 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) {
request.decompress = false;
auto decompressor = makeDecompressionSink(
unpack && hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink);
unpack && absl::EndsWith(mainUrl, ".xz") ? "xz" : "none", sink);
downloader->download(std::move(request), *decompressor);
decompressor->finish();
});
@ -61,7 +62,7 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) {
/* Try the hashed mirrors first. */
if (getAttr("outputHashMode") == "flat")
for (auto hashedMirror : settings.hashedMirrors.get()) try {
if (!hasSuffix(hashedMirror, "/")) {
if (!absl::EndsWith(hashedMirror, "/")) {
hashedMirror += '/';
}
auto ht = parseHashType(getAttr("outputHashAlgo"));