]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Remove superfluous util:: qualifications
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 25 Jul 2023 06:55:14 +0000 (08:55 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 25 Jul 2023 16:08:30 +0000 (18:08 +0200)
15 files changed:
src/util/LockFile.cpp
src/util/LockFile.hpp
src/util/LongLivedLockFileManager.cpp
src/util/TimePoint.hpp
src/util/UmaskScope.cpp
src/util/XXH3_128.hpp
src/util/conversion.hpp
src/util/file.cpp
src/util/file.hpp
src/util/path.cpp
src/util/string.cpp
src/util/string.hpp
src/util/time.cpp
src/util/time.hpp
src/util/zstd.cpp

index bb3f92bec1eb812ce38a0bbdfe9bb843e28405e1..9dc3399e184a26e9e06c89b9cbbf489dd90ecbe1 100644 (file)
@@ -163,8 +163,8 @@ LockFile::release()
   if (m_lock_manager) {
     m_lock_manager->deregister_alive_file(m_alive_file);
   }
-  util::remove(m_alive_file);
-  util::remove(m_lock_file);
+  remove(m_alive_file);
+  remove(m_lock_file);
 #else
   CloseHandle(m_handle);
 #endif
@@ -201,7 +201,7 @@ LockFile::acquire(const bool blocking)
     LOG("Acquired {}", m_lock_file);
 #ifndef _WIN32
     LOG("Creating {}", m_alive_file);
-    const auto result = util::write_file(m_alive_file, "");
+    const auto result = write_file(m_alive_file, "");
     if (!result) {
       LOG("Failed to write {}: {}", m_alive_file, result.error());
     }
@@ -225,9 +225,9 @@ LockFile::do_acquire(const bool blocking)
   ss << get_hostname() << '-' << getpid() << '-' << std::this_thread::get_id();
   const auto content_prefix = ss.str();
 
-  util::TimePoint last_seen_activity = [this] {
+  TimePoint last_seen_activity = [this] {
     const auto last_lock_update = get_last_lock_update();
-    return last_lock_update ? *last_lock_update : util::TimePoint::now();
+    return last_lock_update ? *last_lock_update : TimePoint::now();
   }();
 
   std::string initial_content;
@@ -235,7 +235,7 @@ LockFile::do_acquire(const bool blocking)
                                            k_max_sleep_time * 1000);
 
   while (true) {
-    const auto now = util::TimePoint::now();
+    const auto now = TimePoint::now();
     const auto my_content =
       FMT("{}-{}.{}", content_prefix, now.sec(), now.nsec_decimal_part());
 
@@ -300,8 +300,7 @@ LockFile::do_acquire(const bool blocking)
       last_seen_activity = *last_lock_update;
     }
 
-    const util::Duration inactive_duration =
-      util::TimePoint::now() - last_seen_activity;
+    const Duration inactive_duration = TimePoint::now() - last_seen_activity;
 
     if (inactive_duration < k_staleness_limit) {
       LOG("Lock {} held by another process active {}.{:03} seconds ago",
@@ -314,7 +313,7 @@ LockFile::do_acquire(const bool blocking)
           m_lock_file,
           inactive_duration.sec(),
           inactive_duration.nsec_decimal_part() / 1'000'000);
-      if (!util::remove(m_alive_file) || !util::remove(m_lock_file)) {
+      if (!remove(m_alive_file) || !remove(m_lock_file)) {
         return false;
       }
 
@@ -344,7 +343,7 @@ LockFile::do_acquire(const bool blocking)
   }
 }
 
-std::optional<util::TimePoint>
+std::optional<TimePoint>
 LockFile::get_last_lock_update()
 {
   if (const auto stat = Stat::stat(m_alive_file); stat) {
index 865b9ddcd5662cf476eea37e688fa20ec2ec0438..0176eca40ca52ef09219072625318b7e7075561c 100644 (file)
@@ -70,7 +70,7 @@ private:
   bool acquire(bool blocking);
 #ifndef _WIN32
   bool do_acquire(bool blocking);
-  std::optional<util::TimePoint> get_last_lock_update();
+  std::optional<TimePoint> get_last_lock_update();
 #else
   void* do_acquire(bool blocking);
 #endif
index 4c2d87d9d1053e4894705d33d4ecc6870d0f9496..2e459eaf6246392566a72168a1e8225c340e7428 100644 (file)
@@ -83,7 +83,7 @@ LongLivedLockFileManager::start_thread()
         return;
       }
       for (const auto& alive_file : m_alive_files) {
-        util::set_timestamps(alive_file);
+        set_timestamps(alive_file);
       }
       awake_time += k_keep_alive_interval;
     }
index 9b5756daadd854f5fa3344c644bce57299d6eb38..c35908b41aa5b6ec57fda3769c9e5c7bf48f0a8d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Joel Rosdahl and other contributors
+// Copyright (C) 2022-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -52,10 +52,10 @@ public:
   bool operator<=(const TimePoint& other) const;
   bool operator>=(const TimePoint& other) const;
 
-  TimePoint operator+(const util::Duration& duration) const;
-  TimePoint operator-(const util::Duration& duration) const;
+  TimePoint operator+(const Duration& duration) const;
+  TimePoint operator-(const Duration& duration) const;
 
-  util::Duration operator-(const TimePoint& other) const;
+  Duration operator-(const TimePoint& other) const;
 
 private:
   int64_t m_ns = 0;
@@ -155,21 +155,21 @@ TimePoint::operator>=(const TimePoint& other) const
 }
 
 inline TimePoint
-TimePoint::operator+(const util::Duration& duration) const
+TimePoint::operator+(const Duration& duration) const
 {
   return TimePoint(0, nsec() + duration.nsec());
 }
 
 inline TimePoint
-TimePoint::operator-(const util::Duration& duration) const
+TimePoint::operator-(const Duration& duration) const
 {
   return TimePoint(0, nsec() - duration.nsec());
 }
 
-inline util::Duration
+inline Duration
 TimePoint::operator-(const TimePoint& other) const
 {
-  return util::Duration(0, nsec() - other.nsec());
+  return Duration(0, nsec() - other.nsec());
 }
 
 } // namespace util
index add2a7ca4ed6f179636ab690d49931fced0be4d6..103d6598ccfdbf9a714260ab71d4b67ebe3045d8 100644 (file)
@@ -28,7 +28,7 @@ UmaskScope::UmaskScope(std::optional<mode_t> new_umask)
 {
 #ifndef _WIN32
   if (new_umask) {
-    m_saved_umask = util::set_umask(*new_umask);
+    m_saved_umask = set_umask(*new_umask);
   }
 #else
   (void)new_umask;
@@ -45,7 +45,7 @@ UmaskScope::release()
 #    pragma GCC diagnostic push
 #    pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #  endif
-    util::set_umask(*m_saved_umask);
+    set_umask(*m_saved_umask);
 #  if defined(__GNUC__) && !defined(__clang__)
 #    pragma GCC diagnostic pop
 #  endif
index 13e3e207ce887c035a58e42eca76c3d8b302f67c..ddc52ba14d3ef8c48547a7ab3b67cde483e5da88 100644 (file)
@@ -43,7 +43,7 @@ public:
 
   void reset();
   void update(nonstd::span<const uint8_t> data);
-  util::Bytes digest() const;
+  Bytes digest() const;
 
 private:
   XXH3_state_t* m_state;
@@ -71,13 +71,13 @@ XXH3_128::update(nonstd::span<const uint8_t> data)
   XXH3_128bits_update(m_state, data.data(), data.size());
 }
 
-inline util::Bytes
+inline Bytes
 XXH3_128::digest() const
 {
   const auto result = XXH3_128bits_digest(m_state);
-  util::Bytes digest(k_digest_size);
-  util::int_to_big_endian(result.high64, &digest[0]);
-  util::int_to_big_endian(result.low64, &digest[8]);
+  Bytes digest(k_digest_size);
+  int_to_big_endian(result.high64, &digest[0]);
+  int_to_big_endian(result.low64, &digest[8]);
   return digest;
 }
 
index 841892b7902b9ec43430bf9caa5dc908c60d5047..9eaed5ce6a33a735d8093f47f236438609fa3cc9 100644 (file)
@@ -151,7 +151,7 @@ to_string(const nonstd::span<const uint8_t>& bytes)
 
 template<>
 inline std::string
-to_string(const util::Bytes& bytes)
+to_string(const Bytes& bytes)
 {
   return std::string(to_string_view(bytes));
 }
index afe3bec87d70b2a9ef3312201f226fd9a4132682..4ae2c00a6e24a9a2b855de4f52571567c4f15a85 100644 (file)
@@ -91,8 +91,8 @@ copy_file(const std::string& src,
         FMT("Failed to open {} for writing: {}", dest, strerror(errno)));
     }
   }
-  TRY(util::read_fd(*src_fd, [&](nonstd::span<const uint8_t> data) {
-    util::write_fd(*dest_fd, data.data(), data.size());
+  TRY(read_fd(*src_fd, [&](nonstd::span<const uint8_t> data) {
+    write_fd(*dest_fd, data.data(), data.size());
   }));
 
   dest_fd.close();
@@ -125,7 +125,7 @@ create_cachedir_tag(const std::string& dir)
   if (stat) {
     return;
   }
-  const auto result = util::write_file(path, cachedir_tag);
+  const auto result = write_file(path, cachedir_tag);
   if (!result) {
     LOG("Failed to create {}: {}", path, result.error());
   }
@@ -435,8 +435,8 @@ remove_nfs_safe(const std::string& path, LogFailure log_failure)
 
 void
 set_timestamps(const std::string& path,
-               std::optional<util::TimePoint> mtime,
-               std::optional<util::TimePoint> atime)
+               std::optional<TimePoint> mtime,
+               std::optional<TimePoint> atime)
 {
 #ifdef HAVE_UTIMENSAT
   timespec atime_mtime[2];
index 3ee0e1f06f09716bed7cefb3d54e607aa8f7e62d..54fd574d5266f5e5fc403f61e4f56e07f134b2b9 100644 (file)
@@ -114,8 +114,8 @@ void set_cloexec_flag(int fd);
 // Set atime/mtime of `path`. If `mtime` is std::nullopt, set to the current
 // time. If `atime` is std::nullopt, set to what `mtime` specifies.
 void set_timestamps(const std::string& path,
-                    std::optional<util::TimePoint> mtime = std::nullopt,
-                    std::optional<util::TimePoint> atime = std::nullopt);
+                    std::optional<TimePoint> mtime = std::nullopt,
+                    std::optional<TimePoint> atime = std::nullopt);
 
 // Write `size` bytes from binary `data` to `fd`.
 tl::expected<void, std::string> write_fd(int fd, const void* data, size_t size);
index 9c9b5ca4eb5d0a6033e358b93133123b10aefdd6..ccb0bfbb865df29f6b2b47e7352d839645570bdf 100644 (file)
@@ -57,7 +57,7 @@ apparent_cwd(const std::string& actual_cwd)
   return actual_cwd;
 #else
   auto pwd = getenv("PWD");
-  if (!pwd || !util::is_absolute_path(pwd)) {
+  if (!pwd || !is_absolute_path(pwd)) {
     return actual_cwd;
   }
 
@@ -133,13 +133,13 @@ real_path(std::string_view path)
 std::vector<std::string>
 split_path_list(std::string_view path_list)
 {
-  return util::split_into_strings(path_list, k_path_delimiter);
+  return split_into_strings(path_list, k_path_delimiter);
 }
 
 std::string
 to_absolute_path(std::string_view path)
 {
-  if (util::is_absolute_path(path)) {
+  if (is_absolute_path(path)) {
     return std::string(path);
   } else {
     return Util::normalize_abstract_absolute_path(
index 06320f3d4a16b330f6b4d1012ec1234e35593558..a154d09388e6a8cb16f25899a61f2df449eea2d5 100644 (file)
@@ -107,8 +107,8 @@ format_digest(nonstd::span<const uint8_t> data)
 {
   const size_t base16_bytes = 2;
   ASSERT(data.size() >= base16_bytes);
-  return util::format_base16({data.data(), base16_bytes})
-         + util::format_base32hex(
+  return format_base16({data.data(), base16_bytes})
+         + format_base32hex(
            {data.data() + base16_bytes, data.size() - base16_bytes});
 }
 
@@ -176,7 +176,7 @@ parse_duration(std::string_view duration)
       "invalid suffix (supported: d (day) and s (second)): \"{}\"", duration));
   }
 
-  auto value = util::parse_unsigned(duration.substr(0, duration.length() - 1));
+  auto value = parse_unsigned(duration.substr(0, duration.length() - 1));
   if (!value) {
     return value;
   };
@@ -263,7 +263,7 @@ parse_size(const std::string& value)
 tl::expected<mode_t, std::string>
 parse_umask(std::string_view value)
 {
-  return util::parse_unsigned(value, 0, 0777, "umask", 8);
+  return parse_unsigned(value, 0, 0777, "umask", 8);
 }
 
 tl::expected<uint64_t, std::string>
@@ -384,8 +384,8 @@ replace_first(const std::string_view string,
 std::vector<std::string>
 split_into_strings(std::string_view string,
                    const char* separators,
-                   util::Tokenizer::Mode mode,
-                   util::Tokenizer::IncludeDelimiter include_delimiter)
+                   Tokenizer::Mode mode,
+                   Tokenizer::IncludeDelimiter include_delimiter)
 {
   return split_into<std::string>(string, separators, mode, include_delimiter);
 }
@@ -393,8 +393,8 @@ split_into_strings(std::string_view string,
 std::vector<std::string_view>
 split_into_views(std::string_view string,
                  const char* separators,
-                 util::Tokenizer::Mode mode,
-                 util::Tokenizer::IncludeDelimiter include_delimiter)
+                 Tokenizer::Mode mode,
+                 Tokenizer::IncludeDelimiter include_delimiter)
 {
   return split_into<std::string_view>(
     string, separators, mode, include_delimiter);
index 2c99e34a6f71f4587e9e2f8dd28757e8e8f9b708..c3c207a82245af03f55d5e785b09f909c8bbf049 100644 (file)
@@ -145,12 +145,12 @@ std::string replace_first(std::string_view string,
 
 // Split `string` into tokens at any of the characters in `separators`.
 // `separators` must neither be the empty string nor a nullptr.
-std::vector<std::string> split_into_strings(
-  std::string_view string,
-  const char* separators,
-  util::Tokenizer::Mode mode = util::Tokenizer::Mode::skip_empty,
-  util::Tokenizer::IncludeDelimiter include_delimiter =
-    util::Tokenizer::IncludeDelimiter::no);
+std::vector<std::string>
+split_into_strings(std::string_view string,
+                   const char* separators,
+                   Tokenizer::Mode mode = Tokenizer::Mode::skip_empty,
+                   Tokenizer::IncludeDelimiter include_delimiter =
+                     Tokenizer::IncludeDelimiter::no);
 
 // Split `string` into tokens at any of the characters in `separators`. These
 // tokens are views into `string`. `separators` must neither be the empty string
@@ -158,9 +158,9 @@ std::vector<std::string> split_into_strings(
 std::vector<std::string_view>
 split_into_views(std::string_view string,
                  const char* separators,
-                 util::Tokenizer::Mode mode = util::Tokenizer::Mode::skip_empty,
-                 util::Tokenizer::IncludeDelimiter include_delimiter =
-                   util::Tokenizer::IncludeDelimiter::no);
+                 Tokenizer::Mode mode = Tokenizer::Mode::skip_empty,
+                 Tokenizer::IncludeDelimiter include_delimiter =
+                   Tokenizer::IncludeDelimiter::no);
 
 // Split `string` into two parts using `split_char` as the delimiter. The second
 // part will be `nullopt` if there is no `split_char` in `string.`
index 067b07052b69663dce8be815e29aebd9b373350c..e0ab7eebc97df4703ac8a9bf377b49c1c00f5191 100644 (file)
@@ -21,9 +21,9 @@
 namespace util {
 
 std::optional<tm>
-localtime(std::optional<util::TimePoint> time)
+localtime(std::optional<TimePoint> time)
 {
-  time_t timestamp = time ? time->sec() : util::TimePoint::now().sec();
+  time_t timestamp = time ? time->sec() : TimePoint::now().sec();
 #ifdef HAVE_LOCALTIME_R
   struct tm result;
   if (localtime_r(&timestamp, &result)) {
index 3f263393fd4dc9e876e84279dc53a72f84a08448..9ccfda781e8f89659a5f72f4d08ab9cd79dbe9fd 100644 (file)
@@ -27,6 +27,6 @@ namespace util {
 
 // Thread-safe version of `localtime(3)`. If `time` is not specified the current
 // time of day is used.
-std::optional<tm> localtime(std::optional<util::TimePoint> time = {});
+std::optional<tm> localtime(std::optional<TimePoint> time = {});
 
 } // namespace util
index 4f6f5788bae42f0d2570c3ddf21346e8b817b366..c47139e6b22f5e3a1056a7d786b52f32bf1c2450 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Joel Rosdahl and other contributors
+// Copyright (C) 2022-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -24,7 +24,7 @@ namespace util {
 
 tl::expected<void, std::string>
 zstd_compress(nonstd::span<const uint8_t> input,
-              util::Bytes& output,
+              Bytes& output,
               int8_t compression_level)
 {
   const size_t original_output_size = output.size();
@@ -46,7 +46,7 @@ zstd_compress(nonstd::span<const uint8_t> input,
 
 tl::expected<void, std::string>
 zstd_decompress(nonstd::span<const uint8_t> input,
-                util::Bytes& output,
+                Bytes& output,
                 size_t original_size)
 {
   const size_t original_output_size = output.size();